Stage 1 · Lesson 5 of 10
Promises and async/await
A backend spends most of its time waiting for other things: the database, another service, a file or . So almost every call it makes is , which means the answer comes later. A is a placeholder for a value that arrives later.
An async function always returns one. await pauses that one function until the promise finishes, without stopping the rest of the server. Errors from awaited calls are caught with an ordinary try/catch.
Learn Promise.all to run independent calls at the same time, and Promise.allSettled for when some of them may fail.
Common trapThe traps are forgetting await, so the error escapes your try/catch and the code carries on with an unfinished promise. The other is awaiting inside a loop when the calls do not depend on each other, which turns ten 50 ms calls into ms instead of about 50.
A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- CoursePaidGrokking JavaScript Fundamentals
Design Gurus · Beginner · $50
JavaScript itself in a sensible order: scope, closures, promises and async code
- GuideFreeNode.js Learn
OpenJS Foundation · Beginner
Official guides on the event loop, async work, the http module and environment variables
Practise
Keep handy
Also worth your time
The DNS, TCP, TLS and HTTP steps behind every request your backend will handle