34
rated 0 times
[
40]
[
6]
/ answers: 1 / hits: 15261
/ 9 Years ago, fri, january 29, 2016, 12:00:00
I'm just getting started with async/await
and running into a problem.
I can do as expected:
async function x() {
let y = await Promise.resolve(42);
return y;
}
But when I reject a Promise
:
async function bad() {
try {
await Promise.reject('bad');
} catch(err) {
err; //AssertionError: TypeError: (0 , _errorHandler2.default) is not a function
}
}
How do I catch rejected Promises
with async/await
?
More From » node.js