Skip to content

Instantly share code, notes, and snippets.

@dance2die
Created May 18, 2019 01:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dance2die/684f4772f10e0103c7e306970aa852f6 to your computer and use it in GitHub Desktop.
Save dance2die/684f4772f10e0103c7e306970aa852f6 to your computer and use it in GitHub Desktop.
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