As far as I know, there is a way to get a promise resolved from Promise.all(), event if at least one is rejected.
Promise.all()
// Handling multiple promises even if some fail function dummyPromise(param) { return param !== 5 ? Promise.resolve(param) : Promise.reject('no!!!') } const requests = [{ trello: dummyPromise(1), medium: dummyPromise(2) }, { trello: dummyPromise(3), medium: dummyPromise(4) }, { trello: dummyPromise(5).catch(() => 'no!'), medium: dummyPromise(6) }, ] const promises = [] requests.forEach(req => promises.push(...Object.values(req))) Promise.all(promises) .then(console.log) .catch(console.error) // => [ 1, 2, 3, 4, 'no!', 6 ]
So the idea is to add a catch() to each promise inside Promise.all(). Hope this helps.
catch()
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
As far as I know, there is a way to get a promise resolved from
Promise.all()
, event if at least one is rejected.So the idea is to add a
catch()
to each promise insidePromise.all()
.Hope this helps.