Level 4 · Full-Stack Application Development · Course 4.2 Frontend Architecture
Module 38: API Integration
Goal: connect your React app to an API: fetch data with proper loading and error states, send changes, and use caching so data stays fast and fresh. You'll use a practice API now and your own backend from Module 41.
You'll need: your enquiries app from Module 37 and Module 25's API skills.
Lessons
- 1An API client and a practice server15–25 minutes✓
- 2Fetching with loading and error states15–25 minutes✓
- 3Sending changes15–25 minutes✓
- 4Caching and stale data15–25 minutes✓
- 5Handling real-world API problems15–25 minutes✓
🛠️Module practice: the enquiry app on an API
- An
api.tsclient with typed functions and anApiErrorclass. - Every screen with loading, error (with retry) and empty states.
- Create, update and delete with mutations, disabled buttons while sending, and cache invalidation.
- Sensible
staleTime, background refresh indicator, offline message. - Works against json-server; reports failures clearly when the server is down. Commit.
✅Module check
Explain in a few sentences, in your own words:
What does a good React app do when it talks to an API?
Show a good answer
A good answer mentions: API calls live in one client module that checks responses and throws meaningful errors; screens handle loading, error (with retry) and empty states; changes are sent as mutations with buttons disabled while sending, clear success and failure messages, and refetching or invalidating the cache afterwards. Caching with sensible freshness makes it fast; status codes like 401, 403, 404 and 422 are handled appropriately; data shapes are checked at the boundary, and no secrets are put in frontend code.
📝Module quiz
10 questions · 10 marks each · 100 marks in all · pass mark 70% · retry as often as you like ·
