Send asynchronous browser requests with fetch, XMLHttpRequest, JSON, errors, and progressive UI.
Lessons
Receive a one-way stream of server updates.
Server-Sent Events is easiest to learn by reading the example, changing it, and observing the result.
const source = new EventSource('/api/stream');
source.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log('Update:', data);
};
source.onerror = () => console.warn('Stream lost, browser will retry');Practice the Server-Sent Events example in a small scratch file, then explain what changed and why.