· intermediate
Working with APIs in the Browser
Talking to a server from a page. fetch and the errors it does not throw, cancelling requests that no longer matter, why CORS blocks you, and the loading and error states everybody designs and nobody builds.
Written in house, from the work rather than from a syllabus. Every example is one we would use ourselves, and every quiz question explains why its answer is right.
What you’ll learn
- Handle a fetch response correctly, including statuses that are not errors to fetch
- Abort requests whose results are no longer wanted
- Recognise and prevent the out-of-order response race
- Read a CORS failure and know whose problem it is
- Build the loading, empty and error states as first-class outcomes
- Decide when a retry helps and when it makes things worse
Before you start
- · JavaScript Fundamentals, including promises
- · Some experience building an interface