Send asynchronous browser requests with fetch, XMLHttpRequest, JSON, errors, and progressive UI.
Lessons
Send tokens and API keys with requests.
Authenticated Requests is easiest to learn by reading the example, changing it, and observing the result.
fetch('/api/lessons')
.then(response => {
if (!response.ok) throw new Error(`HTTP ${response.status}`);
return response.json();
})
.then(lessons => console.log(lessons))
.catch(error => console.error(error.message))
.finally(() => console.log('Request complete'));Practice the Authenticated Requests example in a small scratch file, then explain what changed and why.