Skip to content

Instantly share code, notes, and snippets.

@Ifmr24
Created March 26, 2022 00:17
Show Gist options
  • Save Ifmr24/e16a80741fdffd01501741aca639a8fc to your computer and use it in GitHub Desktop.
Save Ifmr24/e16a80741fdffd01501741aca639a8fc to your computer and use it in GitHub Desktop.
allSettled example
const items = Array.from({length: 10})
const handler = async () => {
const promises = await items.map((item) => {
const bool = Boolean(Math.random() < 0.5)
if (bool) {
return Promise.resolve('True')
}else {
return Promise.reject('False')
}
})
const promise_response = await Promise.allSettled(promises)
console.log({promise_response})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment