Handle partial success across requests
Keep useful results without hiding failed dependencies.
Choose the failure policy
Promise.all rejects when any input rejects. That is right when every result is required for a valid screen. Promise.allSettled lets a dashboard render successful cards while labeling failed cards. Decide this at the product level before choosing the API.
Preserve identity
Results must stay attached to the request they came from. allSettled preserves input order, but label each result explicitly if the list can change. Never convert a rejection into an empty array without telling the user; an outage and 'no data' mean different things.
const results = await Promise.allSettled([loadJobs(), loadSkills()]);
const [jobs, skills] = results;
// Render each fulfilled value or its own error state.
Test a mixed outcome
Make one request succeed and the other reject. Confirm that success stays visible, the failed panel gets a retry action, and a retry touches only the failed dependency when feasible. Test total failure too, so the page does not misleadingly claim there are zero jobs or skills.
Check your understanding
When is Promise.allSettled preferable to Promise.all?
Show explanation
When independently useful results should remain available even if another request fails, with each failure shown clearly.
You can read for free. Create an account to save your progress.
← Previous lesson: Handle stale async resultsTry it at foundation level
Request profile and recommendations independently. Draft the UI state when recommendations fail but the profile succeeds.
Check your work
Useful profile data remains visible, the failed panel has a retry action, and the screen does not claim the whole operation succeeded.
Self-guided practice. This does not record assessed mastery.
Put this lesson into practice
A related activity in this module at mid level.
Try: Cancel outdated search requestsFurther reading
Primary references for this module. Check the current version when behavior or framework guidance may have changed.