# How to listen all events using JS sdk

**URL:** <https://forum.flow.com/t/how-to-listen-all-events-using-js-sdk/1438>\
**Category:** ⚙️ Flow SDKs\
**Created:** [March 12, 2021, 10:56am UTC](https://forum.flow.com/t/how-to-listen-all-events-using-js-sdk/1438 "2021-03-12T10:56:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![muddassarshaikh](https://avatars.discourse-cdn.com/v4/letter/m/ad7895/32.png) [@muddassarshaikh](https://forum.flow.com/u/muddassarshaikh)\
**Post date:** [March 12, 2021, 10:56am UTC](https://forum.flow.com/t/how-to-listen-all-events-using-js-sdk/1438/1 "2021-03-12T10:56:34Z")

</div>

Hi All,

I am trying to read events from nbatopshot contracts but getting some error

I have refered this link for events — [FAQ #2 - How to get a list of events?](http://forum.flow.com/t/faq-2-how-to-get-a-list-of-events/539)

But still I am getting error  
Error: failed to get events: could not look up block: key not found

My Sample Code is given below –

const main = async () =\> {

const latestBlock = await fcl.send(await sdk.build([sdk.getLatestBlock()]), {  
node, // mainnet link  
});

const height = latestBlock.block.height;

const eventType = ‘A.0x0b2a3299cc857e29.TopShot.PlayCreated’;

const response = await fcl.send(  
await sdk.build([sdk.getEvents(eventType, 0, height)]),  
{ node } // mainnet link  
);

return response.events;  
};

I have refered also referred this

> **[onflow/flow-js-sdk - GetEvents Usage](https://github.com/onflow/flow-js-sdk/tree/master/packages/sdk#getevents-usage)**
>
> master/packages/sdk

But unable to understand  
From where i will get startBlock and endblock values

Can any one please provide me with sample example

Thanks
