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

162
Views
Cannot re-populate data in async await

I am trying to fetch a data inside for loop and it's using async await and want to populate that data in the existing object array but it doesn't work.

Here is my code:

for (let i = 0; i < listing.length; i++) {
    var listingDetails = null;
    
    (async () => {
      const list = await sdk.listing.query({ listing_id: listing[i].id })
      listingDetails = list.data && list.data.data      // I am expecting this to replace the default value of listingDetails variable
    })()
    
    listing[i].details = listingDetails
    console.log(listingDetails)     // But when it comes here, the listingDetails is still null
}

The last console.log(), I was expecting the data to be there but it wasn't there. Due to this, I am unable to re-populate the details.

about 4 years ago · Juan Pablo Isaza
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!