Send asynchronous browser requests with fetch, XMLHttpRequest, JSON, errors, and progressive UI.
Lessons
Read status, ok, headers, and the body.
The Response Object is easiest to learn by reading the example, changing it, and observing the result.
const response = await fetch('/api/lessons');
console.log(response.ok); // true for 200-299
console.log(response.status); // 200
console.log(response.url);
if (response.ok) {
const lessons = await response.json(); // parse the body once
console.log(lessons.length, 'lessons');
}Practice the The Response Object example in a small scratch file, then explain what changed and why.