One page
HTTP and REST APIs cheat sheet
What to keep at hand. If a line is not clear, go back to the matching lesson in the course.
Open the course: HTTP and REST APIsMethods and statuses
| What | How |
|---|---|
| Read | GET /users/:id |
| Create | POST /users → 201 |
| Update part | PATCH /users/:id |
| Delete | DELETE /users/:id → 204 |
| Don't know who you are | 401 Unauthorized |
| Know you, but no | 403 Forbidden |
Client
| What | How |
|---|---|
| JSON request | fetch(url, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(data) }) |
| Checking | if (!res.ok) throw new Error("HTTP " + res.status) |
| Body | await res.json() |
Cache, errors, real time
| What | How |
|---|---|
| Cache for an hour | Cache-Control: max-age=3600 |
| Don't store | Cache-Control: no-store |
| Version check | If-None-Match: "v42" → 304 |
| Too many requests | 429 + Retry-After: 30 |
| Events from the server | new EventSource("/events") |