JavaScript · Middle · Question 63 of 75
Why do you need two awaits here?
const res = await fetch("/api/user");
const user = await res.json();- ✓Correct answer:
fetchresolves when headers arrive; reading and parsing the body is a separate asynchronous step - 2The second
awaitretries the request - 3It's a style choice; one
awaitis enough
Explanation
The body may still be streaming when headers are available. Check res.ok before parsing, because 4xx/5xx responses don't reject.