I am trying to Fetch the users token from his wallet for which i am able to authenticate using the code below. Using logout() for logging out.
const { Moralis,authenticate,isInitialized, isAuthenticated,isAuthenticating ,user, logout } = useMoralis();
if (!isAuthenticated) {
return (
<Button boxShadow="xl" isLoading={isAuthenticating} onClick={() => authenticate()}>Connect Wallet</Button>
}
But now when i want to fetch the user’s token balances i am getting a bug which says
Unhandled Rejection (Error): [object Object]
Code for fetching balances
const getBalance = async() => {
const balances = await Moralis.Web3API.account.getTokenBalances();
console.log("all token balances of a current user",JSON.stringify(balances));
}
useEffect(() => {
if(isAuthenticated)
{
getBalance();
}
},[isAuthenticated]);