Send asynchronous browser requests with fetch, XMLHttpRequest, JSON, errors, and progressive UI.
Lessons
Configure headers in the fetch options object.
Setting fetch 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 Setting fetch Headers example in a small scratch file, then explain what changed and why.