I keep gettting the error "Unhandled Rejection (TypeError): Cannot read property 'getPastEvents' of undefined"

The affected part of the code is below. Not sure what other info I should provide. Really appreciate any help!

export const loadAllOrders = async (exchange, dispatch) => {
const cancelStream = await exchange.getPastEvents('Cancel', { fromBlock: 0, toBlock: 'latest' })
const cancelledOrders = cancelStream.map((event) => event.returnValues)
dispatch(cancelledOrdersLoaded(cancelledOrders))
}

I cant seem to find anything that works on stacked overflow etc
Really appreciate any help

Sep 3, 2021, 5:31 PM
And what about the code that calls "loadAllOrders"? The error is saying "exchange" is undefined, so you'd wanna look at the calling code to see why
Sep 3, 2021, 6:11 PM
Yeah I been looking at that too and I can't figure it out at all
Sep 3, 2021, 6:34 PM
Feel free to DM me the full code and I can take a look later
Sep 3, 2021, 6:43 PM
Thank you so much ! I will DM you.
Sep 3, 2021, 6:44 PM

© 2024 Draquery.com All rights reserved.