I’m looping through all the chains provided by covalent to get a crosschain balance with:
async function getMultiBalances() {
const chains = await getAllChains();
let totalBalances = [];
let address = await getAddress();
for (let chain of chains) {
let chainId = chain.chain_id;
let balances = await getMultichainBalancesArray(chainId, address);
if (balances.length !== 0) {
totalBalances = [...balances, ...totalBalances];
}
console.log(totalBalances);
}
return totalBalances;
}
console.log(getMultiBalances());
I get the balances array working as seen in the below screenshot, but when trying to return the final balances array it fails. I’m not quite sure what to do, any ideas?