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

114
Vistas
forEach function is not returning values to be added to an array in JS

Im confused why hold is returning nothing -> [] in this function.

Ideally I need to run this request a few times, each response should be added to the array. Why are my values not being added to this list?

const gather = async (round) => {
    console.log("RUNNING");
    const hold = [];
    [...Array(round).keys()].forEach(async (x) => {
      const minLat = -90;
      const minLon = x;
      const maxLat = 90;
      const maxLon = x + 5;
      const params = `minLat=${minLat}&minLon=${minLon}&maxLat=${maxLat}&maxLon=${maxLon}`;
      const url = `URLHERE`;
      const response = await fetch(url);
      const body = await response.text();
      const results = body.split("<raw_text>");
      hold.push(results);
    });
    console.log(hold);
  };
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