27return await promise 27 vs 27return promise 27 in javascript

Solutions on MaxInterview for 27return await promise 27 vs 27return promise 27 in javascript by the best coders in the world

showing results for - " 27return await promise 27 vs 27return promise 27 in javascript"
Giada
25 Feb 2019
1 if the promises successfully resolve, there isn’t a big difference 
2 between using return await promise and return promise.
3
4However, if you want to catch the rejected promise you’re returning
5from an asynchronous function,
6then you should definitely use return await promise expression 
7and add deliberately the await.
8
9catch(error) {...} statement catches only awaited rejected promises
10in try {...} statement.
11
12demos in source url
similar questions