gtryG
Apify & Crawlee2y ago
2 replies
gtry

useState not working as expected.

Hi, I am trying to use the useState method of crawler like below

const mystate = {
  id: new Set()
}

router.addHandler('ABC', async ({ request, crawler, sendRequest, response, body }) => {
    const state = await crawler.useState(mystate);

// now when I try to access the add/has id, I get something like state.id.has is not a function
state.id.has('myid123');
})


I am not sure how useState is supposed to work. can someone shed some light on it.
Thanks
Was this page helpful?