🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Async JavaScript: all 10 questions

Quiz: Async JavaScript · Question 9 of 10

How do you handle errors when using await?

How do you handle errors when using await?

  1. A.You cannot; await hides errors
  2. B.Wrap the awaited calls in try { … } catch (err) { … }
  3. C.Add .finally() to the function name
  4. D.Use setTimeout
Answer & explanation

Correct answer: Wrap the awaited calls in try { … } catch (err) { … }

A rejected promise makes await throw, so try/catch works just like with normal code.

Can you get the rest right without peeking?

Take the timed Quiz: Async JavaScript quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →