Created
March 26, 2022 00:17
-
-
Save Ifmr24/e16a80741fdffd01501741aca639a8fc to your computer and use it in GitHub Desktop.
allSettled example
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 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