JavaScript Promise.all() Explained

JavaScript Logo

Promise.all() – Waits for all promises to fulfill. Rejects immediately if any promise rejects.

๐Ÿ‘‰ Syntax

Promise.all([p1, p2, p3]).then(results => {
  // all results here
});

๐Ÿงช Example

Promise.all([
  fetch('/a'), fetch('/b')
]).then(([a, b]) => console.log('Done'))

Comments