Didn't we already have a Promise.all() what's the difference
Yes, we did. The difference is that Promise.all() didn't resolve the promises from array in then if it had at least one rejected.
Promise.all([Promise.resolve('resolved'), Promise.reject('rejected')]).then((r) => console.log(r)).catch(() => console.log('catch here!')); Output // catch here!
Promise.allSettled([Promise.resolve('resolved'), Promise.reject('rejected')]).then((r) => console.log(r)).catch(() => console.log('catch here!'));
Output // [ // { status: "fulfilled", value: 'resolved' }, // { status: "rejected", reason: 'rejected' } // ]
Ohh cool thanks for clarifying :))
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.
Didn't we already have a Promise.all() what's the difference
Yes, we did. The difference is that Promise.all() didn't resolve the promises from array in then if it had at least one rejected.
Promise.all([Promise.resolve('resolved'), Promise.reject('rejected')]).then((r) => console.log(r)).catch(() => console.log('catch here!'));
Output
// catch here!
Promise.allSettled([Promise.resolve('resolved'), Promise.reject('rejected')]).then((r) => console.log(r)).catch(() => console.log('catch here!'));
Output
// [
// { status: "fulfilled", value: 'resolved' },
// { status: "rejected", reason: 'rejected' }
// ]
Ohh cool thanks for clarifying :))