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

148
Views
Will try-catch catch an error if the function inside of it doesn't have an await in front of it?

Imagine I have the following function:

const test = async () => {
    const response = await axios.get('testurl');
    return response;
}

And then I try to use the function like this:

try {
    test();
} catch (error) {
    // handle errors
}

Will the try-catch block actually catch the error if I call the test() function without an await in front of it in the try-catch block?

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

0

No. Without an await the calling function will not go to sleep and wait for the promise to resolve or error. It will continue running to its own completion.

Later, when the promise errors, the error will be unhandled.

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!