Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var firstPromise = new Promise((resolve, reject) => {
setTimeout(() => {
resolve("Data for Promise One")
}, 3500)
});
var secondPromise = new Promise((resolve, reject) => {
setTimeout(() => {
resolve("Data for Promise Two")
}, 800)
});
var thirdPromise = new Promise((resolve, reject) => {
setTimeout(() => {
reject("Data for Promise Three")
}, 300)
});
var forthPromise = new Promise((resolve, reject) => {
setTimeout(() => {
resolve("Data for Promise Four")
}, 1000)
});
Promise.any([firstPromise, secondPromise, thirdPromise, forthPromise]).then((firstResolvedData) => {
console.log(`Data Received: ${firstResolvedData}`)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment