🤝 Promise.allSettled() VS Promise.all() in JavaScript 🍭 Victor de la Fouchardière on August 16, 2020 Hello ! 🧑🌾 Promises are available since ES2015 to simplify the handling of asynchronous operations. Let's discover 2 Promises and their differe... Read full post Submit Preview Dismiss Collapse Expand Pankaj Patel Pankaj Patel Pankaj Patel Follow Programmer, Blogger, Photographer and little bit of everything Location Lyon, France Work Lead Frontend Engineer at @abtasty Joined Mar 5, 2019 • Aug 17 '20 Dropdown menu Copy link Hide This is a really handy, allSettled has more verbose output Thanks for sharing @viclafouch . Collapse Expand Victor de la Fouchardière Victor de la Fouchardière Victor de la Fouchardière Follow 🐦 Frontend developer and technical writer based in France. I love teaching web development and all kinds of other things online 🤖 Email victor.delafouchardiere@gmail.com Location Paris Education EEMI Work Frontend Engineer Joined Nov 4, 2019 • Aug 17 '20 Dropdown menu Copy link Hide Collapse Expand Arman Khan Arman Khan Arman Khan Follow Fullstack web developer Email armankhan9244@gmail.com Location Surat, India Education Self-taught Work full stack developer at Zypac InfoTech Joined Jul 22, 2019 • Aug 17 '20 Dropdown menu Copy link Hide Loved the article Collapse Expand Victor de la Fouchardière Victor de la Fouchardière Victor de la Fouchardière Follow 🐦 Frontend developer and technical writer based in France. I love teaching web development and all kinds of other things online 🤖 Email victor.delafouchardiere@gmail.com Location Paris Education EEMI Work Frontend Engineer Joined Nov 4, 2019 • Aug 17 '20 Dropdown menu Copy link Hide Thank you @iarmankhan ;) Collapse Expand Suyeb Bagdadi Suyeb Bagdadi Suyeb Bagdadi Follow Joined Aug 26, 2022 • Aug 26 '22 • Edited on Aug 26 • Edited Dropdown menu Copy link Hide You can as well do the following to stop Promise.all from rejecting if there is an exception thrown.`` ` let storage = { updated: 0, published: 0, error: 0, }; let p1 = async (name) => { let status = { success: true, error: false, }; return status; }; let p2 = async (name) => { throw new Error('on purpose'); }; let success = () => { storage.updated += 1; }; let logError = (error) => { console.log(error.message); storage.error += 1; }; Promise.all([ p1('shobe 1').then(success).catch(logError), p2('shobe 2').then(success).catch(logError), p1('shobe 1').then(success).catch(logError), ]).then(() => { console.log('done'); }); ` Collapse Expand Justin Hunter Justin Hunter Justin Hunter Follow VP of Product at Pinata, co-founder of Orbiter - the easiest way to host static websites and apps. Location Dallas Work Software Engineer at Pinata Joined Apr 10, 2019 • Aug 17 '20 Dropdown menu Copy link Hide Whoa! I had no idea this existed. Thanks for the helpful write-up! Collapse Expand Victor de la Fouchardière Victor de la Fouchardière Victor de la Fouchardière Follow 🐦 Frontend developer and technical writer based in France. I love teaching web development and all kinds of other things online 🤖 Email victor.delafouchardiere@gmail.com Location Paris Education EEMI Work Frontend Engineer Joined Nov 4, 2019 • Aug 17 '20 Dropdown menu Copy link Hide A pleasure @polluterofminds ;) Collapse Expand Dayzen Dayzen Dayzen Follow Location Korea Seoul Work Backend Engineer at Smile Ventures Joined Apr 18, 2020 • Aug 17 '20 Dropdown menu Copy link Hide Thanks for sharing this post! Collapse Expand Devin Rhode Devin Rhode Devin Rhode Follow writing javascript for like 8 years or something like that :) Location Minneapolis, MN Work Javascript developer at Robert Half Technology Joined Sep 16, 2019 • Dec 1 '22 Dropdown menu Copy link Hide I'd love some elaboration on why allSettled was made/why it's better Collapse Expand Devin Rhode Devin Rhode Devin Rhode Follow writing javascript for like 8 years or something like that :) Location Minneapolis, MN Work Javascript developer at Robert Half Technology Joined Sep 16, 2019 • Dec 1 '22 Dropdown menu Copy link Hide github.com/tc39/proposal-promise-a... Collapse Expand Yogendra Yogendra Yogendra Follow Location Bengaluru, India Work Web Developer at LayerIV Joined Sep 25, 2020 • Jan 31 '21 Dropdown menu Copy link Hide How can I use Promise.allSettled() with my webpack-react app? Is there any plugin being used for it? Collapse Expand Vladislav Guleaev Vladislav Guleaev Vladislav Guleaev Follow Fullstack Javascript Developer from Munich, Germany. Location Munich, Germany Education Computer Science - Bachelor Degree Work Software Developer at CHECK24 Joined Apr 8, 2019 • Jun 8 '21 Dropdown menu Copy link Hide short and nice! Collapse Expand Mohd Aliyan Mohd Aliyan Mohd Aliyan Follow I am a software Engineer looking for each day of learning. Joined Oct 6, 2021 • Oct 6 '21 Dropdown menu Copy link Hide Very well explained. Thank you so much Victor. Collapse Expand Shakhruz Shakhruz Shakhruz Follow JavaScript enthusiast Location Tashkent, Uzbekistan Work Junior Full-Stack developer at Cruz Joined Dec 27, 2020 • Jan 5 '21 Dropdown menu Copy link Hide Helpful bro, thnx !!! Code of Conduct • Report abuse
This is a really handy,
allSettledhas more verbose outputThanks for sharing @viclafouch .
Loved the article
Thank you @iarmankhan ;)
You can as well do the following to stop Promise.all from rejecting if there is an exception thrown.``
`
let storage = {
updated: 0,
published: 0,
error: 0,
};
let p1 = async (name) => {
let status = {
success: true,
error: false,
};
return status;
};
let p2 = async (name) => {
throw new Error('on purpose');
};
let success = () => {
storage.updated += 1;
};
let logError = (error) => {
console.log(error.message);
storage.error += 1;
};
Promise.all([
p1('shobe 1').then(success).catch(logError),
p2('shobe 2').then(success).catch(logError),
p1('shobe 1').then(success).catch(logError),
]).then(() => {
console.log('done');
});
`Whoa! I had no idea this existed. Thanks for the helpful write-up!
A pleasure @polluterofminds ;)
Thanks for sharing this post!
I'd love some elaboration on why allSettled was made/why it's better
github.com/tc39/proposal-promise-a...
How can I use Promise.allSettled() with my webpack-react app? Is there any plugin being used for it?
short and nice!
Very well explained. Thank you so much Victor.
Helpful bro, thnx !!!