DEV Community

Discussion on: Async & await explained in short

Collapse
 
lico profile image
SeongKuk Han

I didn't know that can use the 'catch' to an await function.
I've been used only try-catch block for catching errors. and I've just known that only works.
Thanks for your post :)

Collapse
 
rahxuls profile image
Rahul

Welcome!

Collapse
 
hnicolas profile image
Nicolas Hervé

You can use catch on a promise and it will return another promise.
You can use await on a promise to wait for the result.
So everything is ok with the example, even if with the await keyword you can use a try/catch block to catch the error rejected by a promise.

Collapse
 
lico profile image
SeongKuk Han

Thank you :DD