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

184
Visualizações
How to fetch data from multiple API's at the same time - that require a different seaarch prase

I'm making an app that fetches data from 2 different APIs at the same time based on the user's search.

The app is supposed to fetch current crypto prices and historical data. But the APIs use 2 different formats for the symbol, like so:

1.

  • BTC-USD (yahoo.com/BTC-USD)
  • BITCOIN (coingecko.com/api/BITCOIN)

if someone looks up 'BITCOIN' it's only going to pull up data from 1 API, because the other 1 requires 'BTC-USD'

2.

  • ETH-USD (yahoo.com/ETH-USD)
  • ETHEREUM coingecko.com/api/ETHEREUM

Is it possible to somehow fetch data from both APIs at the same time-based?

I guess I could see some solutions (hardcoding the data, or switching APIs so they use the same format), altho this path seems pretty work-intensive.

Any ideas on how this can be done?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Use Promise.all if you want fetch data from 2 different API's at the sane time:

const fetchData = async (yahoo_API_URL, coingecko_API_URL) => {
    const fetchYahoo = fetch(yahoo_API_URL, /* config */)
    const fetchCoingecko = fetch(coingecko_API_URL, /* config */)
    const [fetchYahooRes, fetchCoingeckoRes] = await Promise.all([fetchYahoo, fetchCoingecko])
    const [cryptoPriceFromYahoo, cryptoPriceFromCoingecko] = await Promise.all([fetchYahooRes.json(), fetchCoingeckoRes.json()])
    ...
  }

  fetchData('yahoo.com/BTC-USD', 'coingecko.com/api/BITCOIN')
  fetchData('yahoo.com/ETH-USD', 'coingecko.com/api/ETHEREUM')
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