awaitare syntactic sugar for
awaitcan be user in
awaitpauses the executin of
asyncfunction untill the
Promiseis resolved a.k.a the result is known.
Promiseis rejected the rejection reason is thrown. Therefore itis better to use
Errorinstance as a reason.
let res = await promise.catch(err => console.error(err));.
reswill be indefined in promise was rejected.