Last active
December 22, 2023 05:53
-
-
Save Karan-Palan/74f7bb8b2f59bb70093d02112e413ea7 to your computer and use it in GitHub Desktop.
Promise.allSettled(PromiseAPIs)
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
// Promise.all Settled | |
const p1 = new Promise((resolve, reject) => { | |
setTimeout(() => resolve("P1 Sucess"), 3000); | |
}); | |
const p2 = new Promise((resolve, reject) => { | |
//setTimeout(() => resolve("P2 Sucess"), 1000); | |
setTimeout(() => reject("P2 failure"), 1000); | |
}); | |
const p3 = new Promise((resolve, reject) => { | |
setTimeout(() => resolve("P3 Sucess"), 2000); | |
}); | |
Promise.allSettled([p1, p2, p3]) | |
.then((res) => { | |
console.log(res); | |
}) | |
.catch((err) => { | |
console.error(err); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment