Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Medium Promise-Bonus tip example
const dog = new Promise((resolve, reject) => {
setTimeout(() => {
resolve('🐶');
console.log('I am still executing!!');
}, 1000);
})
const cat = new Promise((resolve, reject) => {
setTimeout(() => {
reject('🐈');
console.log('Even I am!!');
}, 2000)
})
Promise.all([dog, cat]).then((values) => {
console.log(values)
}).catch((error) => {
console.log('error =>',error);
})
/*
Console Output:
I am still executing!!
Even I am!!
error => 🐈
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment