jsverse
Async & Browser JS / Fetch

fetch & JSON

Requesting data over the network, promise-based from start to finish.

`fetch()` returns a promise that resolves once the response headers arrive - not once the full body is downloaded. Reading the body (as JSON, text, etc.) is a second, separate asynchronous step via `response.json()`, which also returns a promise. Both steps are usually awaited in sequence.

Codeeditable — Run and Step both follow your edits
Loading...
Console
Output will appear here
Visualization
Result
Press Step to watch each line's result appear here
Why?

fetch resolves as soon as headers/status are known - the body might still be streaming in, which is exactly why reading it with .json() is its own separate await.