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

202
Views
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 answers
Answer question

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 Report
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!