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

204
Vistas
underscore.each will complete cycle instead await inside

I've a _each() that inside got an await where I check a user state in MySQL

the mysql response return after cycle is already completed. there is a way that wait the method checkUserState(), beforse and than go to next element of _each()?

 let obj = _.each(guest_list.guests, async function (value){
     let user_state = await DataController.checkUserState('2305');
    value.Owner.state = user_state;
    console.log('state:' + user_state);
    return value;
  });

  console.log('cycle complete')
 return obj;

Result is: cycle complete state:notdisturb state:notdisturb state:notdisturb state:notdisturb state:notdisturb state:notdisturb state:notdisturb state:notdisturb state:notdisturb state:notdisturb state:notdisturb state:notdisturb

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You need to use Promise.all

 let obj = await Promise.all([_.map(guest_list.guests, async function (value){ let user_state = await DataController.checkUserState('2305'); value.Owner.state = user_state; return value; })]);

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