Using Promise.all to Resolve Multiple Promises in Javascript


Wait for multiple promises to resolve.

Source Code

let promise1 = Promise.resolve(3);
let promise2 = 42;
let promise3 = new Promise((resolve, reject) => {
  setTimeout(resolve, 100, 'foo');
});

Promise.all([promise1, promise2, promise3]).then(values => {
  console.log(values); // [3, 42, "foo"]
});
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments