Hi, I’m trying to get all the nfts an account has. I heard that Moralis.Web3API.account.GetNFTs
will be deprecated in moralis nitro. So I’m trying to do it will multiple getNFTBalance calls like this:
const { getNFTBalances } = useNFTBalances();
const [nftCollection, setNftCollection] = useState([]);
useEffect(() => {
const current_user = Moralis.User.current();
const accounts = current_user.get("accounts")
accounts.forEach(account => {
getNFTBalances({
params: {chain: "ropsten", address: account},
onSuccess: (data) => {
console.log("data", ...data.result);
console.log("collection", ...nftCollection);
setNftCollection([...nftCollection, ...data.result]);
}
})
});
}, [])
But when I do this nftCollection isn’t getting accumulated. I’m not the best with javascript. Any idea what the right way to do this would be.