Created
July 19, 2022 11:53
-
-
Save szaranger/620a09877a97ab57cfee2e23628f2528 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| async function run() { | |
| const settledPromises = Promise.allSettled([ | |
| new Promise((r, reject) => setTimeout(() => reject("Out of stock"), delay)), | |
| new Promise((r, reject) => setTimeout(() => reject("Out of stock"), delay)) | |
| ]); | |
| // wait... | |
| const promises = await settledPromises; | |
| // after 0.8 seconds | |
| console.log(promises); | |
| /* | |
| [[object Object] { | |
| reason: [object Error] { ... }, | |
| status: "rejected" | |
| }, [object Object] { | |
| reason: [object Error] { ... }, | |
| status: "rejected" | |
| }] | |
| */ | |
| } | |
| run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment