Good day - not really sure where I am going wrong with regard to the prevpage function - next is working perfectly fine
const [nftBalances, setNftBalances] = useState([]);
const [nameSet, setName] = useState("");
const [page, setPage] = useState("");
const [pg, setPg] = useState();
const [cursor, setCursor] = useState();
const {Web3Api} = useMoralisWeb3Api();
const {isInitialized, Moralis, account,isWeb3Enabled, enableWeb3} = useMoralis()
const router=useRouter()
const id = router.query.id
const fetchContract = async()=>{
const options = {
chain: "rinkeby",
address: id,
};
const nfts = await Moralis.Web3API.token.getNFTOwners(options);
let nftBalance = nfts.result;
console.log(nfts)
console.log(nfts.page)
setPage(nfts)
setPg(nfts.page)
setCursor(nfts.cursor)
setName(nftBalance[0]?.name)
setNftBalances(nftBalance)
}
async function nextPage(){
const next = await page.next()
let nftBalance = next.result
const pg = next.page
setCursor(next.cursor)
setPg(pg)
setNftBalances(nftBalance)
setPage(next)
console.log(next)
}
console.log(pg)
async function prevPage(){
const options = {
chain: "rinkeby",
address: id,
cursor: cursor,
}
const nfts = await Moralis.Web3API.token.getNFTOwners(options);
let nftBalance = nfts.result;
console.log(nfts)
console.log(nfts.page)
setPage(nfts)
setPg(nfts.page)
setCursor(nfts.cursor)
setNftBalances(nftBalance)
}