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

118
Visualizações
How I can save many Fetchs in one array?

I am using PokeApi and I want to save data that is inside of another API using its ID´s, but it could be more than 1 so I want to save it in a array. By now I am using two methods, one get the api and verify if the information is there.

const evolutionChain = async (URLEC)=> {
  var chain=[]
  const getURL= await fetch(URLEC);
  const res1 = await getURL.json();
  chain.push(getPoke(res1.chain.species.url));
  if(res1.chain.evolves_to.length!==0){
    chain.push(getPoke(res1.chain.evolves_to[0].species.url));
  }
  if(res1.chain.evolves_to[0].evolves_to[0].length!==0){
    chain.push(getPoke(res1.chain.evolves_to[0].evolves_to[0].species.url));
  }
  return chain;
}

URLEC is "https://pokeapi.co/api/v2/evolution-chain/1/".

And the other function get the another URL and get the info

const getPoke= async (url)=>{
  const getURL= await fetch(url);
  const res1 = await getURL.json();
  const res2 = await fetch( `https://pokeapi.co/api/v2/pokemon/${res1.id}`);
  const res3 = await res2.json();
  const poke= {
    name: res3.name
  }
  return poke;
}

At the end it returns me the entire promise that have an array of promises like this: Results

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