Caffeinated Coder
Book an appointment
Lesson 21 · Async JavaScript

fetch: talking to servers

fetch(url) is how a page asks a server for data: it sends an HTTP request and hands back a promise straight away. Follow an eight-line script that loads one user, from the request and the paused await, through the response, the res.ok check and res.json(), to the printed name, and see why a 404 reply does not make fetch fail on its own.

11 min11 steps5 questionsIntermediate
Fig 21 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.