Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

101
Visualizações
how to get function return response out of {"_U": 0, "_V": 0, "_W": null, "_X": null}

I'm trying to call a function in loop and function doing some https request the response is returning back to function and it returns :

{"_U": 0, "_V": 0, "_W": null, "_X": null}

I want to return the exact value to that key where the function is called in the loop.

Here is my code :

 res.forEach(async (elem, index) => {
      await arr.push({
        id: index,
        name: '',
        color: '#2F14A8',
        chain: elem.chain,
        address: elem.walletAddress,
        balance: getWalletBalance(elem.walletAddress), //<---- **function call**

        img: images[index % images.length],
      });
    });

Here is the function :

const getWalletBalance =async address => {

let tokensArr=[] // some arry

    const res = await dispatch(getBalanc(address, tokensArr));
    return res;
    
    }
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

What is the response for res in getWallertBalance function? I think if u put await before getWalletBalance(elem.walletAddress) in forEach solves the problem!

about 4 years ago · Juan Pablo Isaza Relatório

0

Those individual calls to getWalletBalance don't appear to depend on each other. The best way to do this is to produce a collection of promises with map, the resolve them concurrently...

const getWalletBalance = async address => {
  const res = await dispatch(getBalanc(address, tokensArr));
  const promises = res.map(element => getWalletBalance(elem.walletAddress));
  const balances = await Promise.all(promises);
  return res.map((element, index) => {
    return {
      id: index,
      name: '',
      color: '#2F14A8',
      chain: element.chain,
      address: element.walletAddress,
      balance: balances[i],
      img: images[index % images.length],
    };
  })
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda