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

164
Vistas
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
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