getAllERC20 balance api giving cors issue when passed with chain=bsc

  • I am calling getAllERC20({address, chain: ‘bsc’}); its giving me cors issue on localhost. while if i call the same api without chain its working fine.
1 Like

Hey @sumitc

You have a syntax mistake:

getAllERC20({address, chain : 'bsc'})

sorry. I am calling with the right syntax. just wrote it here wrong. previously it used to work. suddenly it started giving me cors issue. updated my server also.

You may be calling too many requests at the same time :face_with_monocle:

I’m having the same issue with the bsc chain, not doing much calls, all was working before

export const getAllTokens = async (address, chain) => {
  const options = {
    chain,
    address,
    order: "desc",
  };
  const web3 = getWeb3Chain(chain);

  let balances = await Moralis.Web3.getAllERC20(options);

  balances = balances.map((balance) => {
    if (balance.balance !== 0) {
      balance.balance = web3.utils.fromWei(balance.balance);
    }
    return balance;
  });

  balances = balances.filter((balance) => balance.balance !== "0");

  return balances;
};

no…only 1 request at a time.

We found the issue, fix coming

Hey @sumitc @renanlopescoder

We have fixed this issue :man_factory_worker:. Now it works correctly!

Thank you for your patience :open_hands:

3 Likes