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

89
Views
Async function is NOT waiting properly

So i have a main function that is async and it awaits my other function.

main = async () => {
  await this.getResult();
  console.log("end2")
}

so here is the getResult function

getResult() = async () => {
  const result= await fetch(``, this.requestOptions)
  console.log("end1");
  Promise.all(a.map(async b => {
    console.log("Transaction", trabnsaction);
  }))
}

end2 gets printed out first.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You should add the await in the Promise.all as well.

getResult() = async () => {
    const result= await fetch(``, this.requestOptions)

    console.log("end1");

    await Promise.all(a.map(async b => {
        console.log("Transaction", trabnsaction);

    }))
}
about 4 years ago · Juan Pablo Isaza Report

0

You need to return Promise.all, also you need to return a promise from the map method.

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!