Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

381
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!