Send asynchronous browser requests with fetch, XMLHttpRequest, JSON, errors, and progressive UI.
Lessons
Control credentials with the credentials option.
Sending Cookies & Credentials is easiest to learn by reading the example, changing it, and observing the result.
// Include cookies on a cross-origin request
const res = await fetch('https://api.example.com/me', {
credentials: 'include' // 'same-origin' (default) | 'include' | 'omit'
});
// The server must also send:
// Access-Control-Allow-Credentials: truePractice the Sending Cookies & Credentials example in a small scratch file, then explain what changed and why.