Created
May 18, 2019 01:36
-
-
Save dance2die/684f4772f10e0103c7e306970aa852f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const promisesWithoutReject = [ | |
Promise.resolve('π #1'), | |
'π #2', | |
new Promise((resolve, reject) => setTimeout(resolve, 100, 'π #3')) | |
] | |
Promise.all(promisesWithoutReject) | |
.then(apples => console.log(`We can sell all these good apples`, apples)) | |
const promisesWithOneReject = [ | |
Promise.resolve('π #1'), | |
'π #2', | |
new Promise((_, reject) => setTimeout(reject, 100, 'Bad π')) | |
] | |
Promise.all(promisesWithOneReject) | |
.then(console.log) | |
.catch(badApple => | |
console.error(`Threw out all apples because of this`, badApple)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment