Await the request
Take your time, follow the code and check your understanding.
The codeNode.js requests and async
async function load() {
const response = fetch("https://example.com/data");
return response.json();
}Your answer4 min · no timer
Show solution and explanation
fetch returns a Promise. Await it to obtain a Response before calling json(). Also handle non-success HTTP statuses in real code.
Add await before fetch.