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

283
Visualizações
Javascript/React How to return data from a promise?

I'm pulling prices from an api, and I have a function where I pull the prices, and return a formatted version of them.

          const res = await CoinGeckoClient.coins.fetch(farm.quoteToken.name)
          // console.log(res)
          const data = await res.data
          const unformatted_price = new BigNumber(data.market_data.current_price.usd).toString()
          // console.log(earn_price)
          const formatted_price = parseFloat(unformatted_price).toLocaleString(undefined, {
            minimumSignificantDigits: 3,
          })

          return formatted_price
        }

Inside of the function, if I console.log(formatted_price) it gives me the result I'm looking for. However when I return it to use when calling the function, I get a pending fulfilled promise. I'm trying to get the promise result as shown.

Sort of confused on how it's pending, but it's fulfilled with a result? I've tried .then() and everything but I continue to get Promise {}. Any help would be appreciated!

enter image description here

about 4 years ago · Juan Pablo Isaza
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