📜  JavaScript 代码示例中的“返回等待承诺”与“返回承诺”

📅  最后修改于: 2022-03-11 15:03:52.888000             🧑  作者: Mango

代码示例1
if the promises successfully resolve, there isn’t a big difference 
 between using return await promise and return promise.

However, if you want to catch the rejected promise you’re returning
from an asynchronous function,
then you should definitely use return await promise expression 
and add deliberately the await.

catch(error) {...} statement catches only awaited rejected promises
in try {...} statement.

demos in source url