The below code:
import { useMoralis, useMoralisWeb3Api } from "react-moralis";
export default function AnalyticsSales() {
const { Moralis } = useMoralis();
Moralis.initPlugins();
useEffect(async () => {
const GetTokenBalancesForAddressDto = {
chainId: 1,
address: "0xc9d0556c8011856098fc6c8fae638b7e338ede5a",
};
const covalentTokenBalances =
await Moralis.Plugins.covalent.getTokenBalancesForAddress(
GetTokenBalancesForAddressDto
);
const tokenBalances = covalentTokenBalances.data.items;
console.log(tokenBalances);
}, []);
Will give off errors randomly, meaning sometimes it gives this error sometimes it doesnāt. It seems Moralis object fails to initialize sometimes (unreliable).
Errors:
Unhandled Runtime Error
Error: You need to call Parse.initialize before using Parse.
Not even using parse so this is weird.
Unhandled Runtime Error
TypeError: Cannot read properties of undefined (reading 'covalent')
Using react with next.js, MoralisProvider is configured correctly and working (sometimes i guess).
Any ideas on how to make this more reliable and work?