Promise.allSettled ไม่หยุดแม้ promise ตัวใดตัวหนึ่ง reject
Promise.all หยุดทันทีเมื่อมี reject — Promise.allSettled รอทุกตัวจบแล้วค่อยรายงานผลแยก fulfilled/rejected
Promise.all short-circuit — reject ตัวเดียว ทุกตัวพัง:
const results = await Promise.all([fetchA(), fetchB(), fetchC()]);
// ถ้า fetchB() reject → results ไม่มีค่า, error throw ออกมาเลย
Promise.allSettled รอทุกตัวเสมอ แล้วส่งกลับเป็น array ของ status object:
const results = await Promise.allSettled([fetchA(), fetchB(), fetchC()]);
results.forEach((r) => {
if (r.status === 'fulfilled') console.log(r.value);
if (r.status === 'rejected') console.error(r.reason);
});
ใช้ Promise.allSettled เมื่อ request แต่ละตัว independent กัน และอยากรู้ว่าตัวไหนสำเร็จ/ล้มเหลวบ้าง — เหมาะกับ dashboard ที่โหลดหลาย widget พร้อมกัน