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

382
Vistas
Fetch API multiple Times and store the result in Array, gives an empty Array ( Vanilla.js )

I have an array of area code const regions = [123,12312,1231231,123123,123123]

and

I have an End Point something like https:service.org?where=id=${code}

Data that I get from response looks something like this:

features: [{data}]

Now All I am trying to do is get the response, store it in the array, and create a JSON File. Here is the snippet of the code, that I have

const getResponse = async () => {
 
    let responseData =[]
    regions.forEach(async (code)=> {
        const response = await fetch(`https://services.org?where=id=${code}`); 
        const data = await response.json();
        
        responseData.push(data.features[0])
    })

    console.log(responseData)
}

When I console.log the response data it provides me an Empty Array and I am not sure why it is behaving like this.

about 4 years ago · Santiago Gelvez
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