Send asynchronous browser requests with fetch, XMLHttpRequest, JSON, errors, and progressive UI.
Lessons
Fetch data from public and partner APIs.
Calling Third-Party APIs is easiest to learn by reading the example, changing it, and observing the result.
const BASE = 'https://api.example.com';
export const api = {
list: () => fetch(`${BASE}/lessons`).then(r => r.json()),
get: (id) => fetch(`${BASE}/lessons/${id}`).then(r => r.json()),
create: (data) => fetch(`${BASE}/lessons`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data)
}).then(r => r.json())
};Practice the Calling Third-Party APIs example in a small scratch file, then explain what changed and why.