Pagination in react JS using axios

Hi all,

I’m currently using a moralis API call to display all the owners of NFTs in my collection. However it only loads the first 100. Is there a way to loop through the entire collection of 10,000 NFTs?

I imagine this is where I would need to do it - any number over 100 after the limit just fails.

let config = {‘X-API-Key’: moralisapikey, ‘accept’: ‘application/json’};

    const nfts = await axios.get((moralisapi + `/nft/${NFTCONTRACT}/owners?chain=polygon&format=decimal&limit=100`), {headers: config})

    .then(output => {

    const { result } = output.data

    return result;

  })

You can store your initial result in a state and update the state by adding more data gotten from next result.

you can look at this python example:
https://docs.moralis.io/misc/rate-limit#example-of-how-to-use-cursor-python