Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save djmarland/77fffb5b0fe5473797901fad1872a9b6 to your computer and use it in GitHub Desktop.
Save djmarland/77fffb5b0fe5473797901fad1872a9b6 to your computer and use it in GitHub Desktop.
var p1 = new Promise((resolve, reject) => {
setTimeout(resolve, 1000, 'p1_delayed_resolvement');
});
var p2 = new Promise((resolve, reject) => {
reject(new Error('p2_immediate_rejection'));
});
Promise.all([
p1.catch(error => { return error }),
p2.catch(error => { return error }),
]).then(values => {
console.log(values[0]) // "p1_delayed_resolvement"
console.log(values[1]) // "Error: p2_immediate_rejection"
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment