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

391
Visualizações
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 à 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