Lesson content
Read, practise, then check your understanding
localStorage persists origin-scoped strings; sessionStorage lasts for one origin/tab session. Both are synchronous, capacity-limited, and unsuitable for secrets. IndexedDB fits larger structured data.
Fetch with boundaries
const controller = new AbortController();
const response = await fetch("/api/lessons", {
signal: controller.signal,
headers: { Accept: "application/json" }
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const data = await response.json();
Fetch rejects for network failure, not ordinary HTTP error status. Validate response type/data, define timeouts/cancellation, and encode requests correctly. Storage events can notify other tabs. Treat all client storage as user-controlled and avoid blocking large serialization on the main thread.
Knowledge check
Answer every question correctly to complete this chapter.
0 of 10 checks passed
Your progress is saved on this device.