getNFTs pagination with .next() not working correctly

Hi, I am trying to use .next() for pagination of getNFTs (https://docs.moralis.io/moralis-dapp/web3-api#web3-api-pagination-examples-with-.next), however, it does not seem to work correctly.

Here is the code:

const options = {
    chain: "eth",
    address: "0x1f861b04Aba9d12B7d567Bd91ae67EE7b9b2f879",
    limit: 20,
  };
  let nfts = await Moralis.Web3API.account.getNFTs(options);
  let data: any[] = nfts.result || [];
  while (nfts.next) {
    nfts = await nfts.next();
    data.push(...(nfts.result || []));
  }
  console.log(data.length);

If I use limit: 20, it will return 60 NFTs; if I use limit: 10, it will return 70 NFTs; if I use limit: 50, it will return 50 NFTs; and if I use limit: 100, it returns 75 NFTs.

So apparently when it comes to the last page, next becomes null but it shouldn’t be.

Can anyone help me on this?

There is an issues that we know about. It doesn’t return the last page. You can use the cursor directly if you want.

@wd20060220, it should work now with the latest version of the sdk