Send asynchronous browser requests with fetch, XMLHttpRequest, JSON, errors, and progressive UI.
Lessons
Send Accept, Content-Type, and custom headers.
Request Headers is easiest to learn by reading the example, changing it, and observing the result.
const response = await fetch('/api/lessons', {
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer ' + token,
'X-Requested-With': 'XMLHttpRequest'
}
});Practice the Request Headers example in a small scratch file, then explain what changed and why.