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

113
Vistas
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 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