Back to case studies
Node.jsFundamental
Running asynchronous tasks with Promise.all
Scenario
Context A data aggregation script fetches information from three different APIs and combines the results into a single report. The Problem The current script awaits each API call sequentially, taking 3 seconds total when all three could run in parallel in 1 second. Current Code const a = await fetchA(); const b = await fetchB(); const c = await fetchC(); Constraints Refactor to run all three fetch calls in parallel with Promise.all. Handle the case where any one of them fails without blocking the others using Promise.allSettled. Log which calls succeeded and which failed. Expected Deliverable A Node.js script using Promise.all and Promise.allSettled to run concurrent async operations with individual failure handling.
Targeted skills
nodejspromisesasyncparallelpromise-all