Parallel resolution of promises

You may need to resolve each promises within the parent separately to make sure that the Promise.all catches it just fine.

e.g,

const nestedAsyncChild = new Promise(resolve => resolve(someMethod));
const asyncChild = new Promise(resolve => resolve(nestedAsyncChild));

const parent1 = new Promise(resolve => resolve(asyncChild));
const parent2 = new Promise(resolve => resolve(asyncChild));
const parent3 = new Promise(resolve => resolve(asyncChild));

Promise.all([parent1, parent2, parent3])
.then(a => {
  console.log("Success");
})
.catch(() => {
  console.error("Error");
});

Update

If someone is down-voting an answer they should have the common courtesy to tell the person why that was being done. Chasing people off the answer-board does not help!

Leave a Comment