Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

280
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda