Reputation: 63
Why is the result of the promise still undefined
? Tutorial says it's gonna be error
.
Is it a Chrome display issue or anything I don't comprehend so far?
Upvotes: 1
Views: 70
Reputation: 370619
You aren't returning anything from the error handler (alert
returns undefined
), so the Promise result tied to the error is undefined
. If you return something from the error handler, you'll see it in the result.
new Promise((resolve, reject) => {
setTimeout(() => {
reject('err');
}, 1000);
})
It's not a Chrome thing - this is how it'd work in any environment. (To access the error result, call .catch
on the Promise and use the first argument)
Upvotes: 1