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

160
Views
Awaiting a void function in javascript

Hi I was wondering how I could await a void function. I tried the following (mock up):

async function asyncer() {
  setTimeout(() => {
    console.log("async msg")
  }, 0)
}

async function helloer() {
  await asyncer()
  console.log("hello")
}

helloer()

This however doesn't work, so I tried the following :

async function asyncer() {
  setTimeout(() => {
    console.log("async msg")
  }, 0)
  return true
}

async function helloer() {
  let ready = await asyncer()
  if (ready) {
    console.log("hello")
  }
}

helloer()

Still "hello" is still logged before "async msg". Does anyone know a solution to this problem. Thanks in advance.

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

0

async/await is a syntax sugar for promise.then, so create a Promise.resolve or smth to enter in async flow and then use async/await

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!