[SOLVED] How to use "cursor" with useEvmWalletNFTs() from @moralisweb3/react

Using the latest @moralisweb3/react ( https://www.npmjs.com/package/@moralisweb3/react )
The hooks are working generally nice but when getting larger responses they get cut at 100.
E.g. with useEvmWalletNFTs() !

How can I get “total”, “page size”, “cursor”, etc ?!

Hi @rmwa

You can loop through all the pages using the cursor. You can find more details on how to loop through the cursor in this doc page.

While using the useEvmWalletNFTs() you will have to use the fetch function from this hook to run a loop on all the pages.

const {fetch} = useEvmWalletNFTs()

Thanks a lot for your reply @johnversus !

Yes, have worked with the cursor in the past, but my issue is that the call of the hook does not reply the meta data like “page size”, “total”, “cursor” etc. - but only an array with the NFT data (without that “meta data”) is being returned. This is capped at 100 but need to get to more data.
This is how I do it now:
// const { data: balance } = useEvmWalletTokenBalances({ address: ‘0x…da’ });
// console.log(balance);

Is there any documentation for the @moralisweb3/react webhooks or do you have a code example ?!

Hi @rmwa

I could see the cursor and other data in the response from fetch function.

This is how I used it.

const { fetch: fetchNFT } = useEvmWalletNFTs();

  useEffect(() => {
    fetchNFT({
      address: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
      chain: 1,
    }).then((data) => { 
      console.log(data);
    });
  }, []);

And also use “data” not “{data}” or else it might return just the data array without cursor.

Let us know if this helps.

Thanks a lot @johnversus :+1:

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.