HTTP Methods
Common request methods and the intent they usually communicate.
| Term / Syntax | Name | Description | Example |
|---|---|---|---|
GET |
Read Resource | Requests a representation of a resource without intending to modify it. | GET /api/users/42 |
POST |
Create/Process | Submits data for processing or commonly creates a new resource. | POST /api/users |
PUT |
Replace Resource | Commonly replaces a resource with the complete representation provided. | PUT /api/users/42 |
PATCH |
Partial Update | Applies partial modifications to a resource. | PATCH /api/users/42 |
DELETE |
Delete Resource | Requests removal of the target resource. | DELETE /api/users/42 |
Common Status Codes
Frequently encountered HTTP response status codes.
| Term / Syntax | Name | Description | Example |
|---|---|---|---|
200 |
OK | The request succeeded. | 200 OK |
201 |
Created | The request succeeded and created a new resource. | 201 Created |
204 |
No Content | The request succeeded and has no response body. | 204 No Content |
400 |
Bad Request | The server could not process the request because the request was invalid or malformed. | 400 Bad Request |
401 |
Unauthorized | Authentication is required or has failed. | 401 Unauthorized |
403 |
Forbidden | The server understood the request but refuses authorization. | 403 Forbidden |
404 |
Not Found | The requested resource was not found. | 404 Not Found |
409 |
Conflict | The request conflicts with the current state of the resource. | 409 Conflict |
500 |
Internal Server Error | The server encountered an unexpected error while processing the request. | 500 Internal Server Error |
Headers & JSON
Common metadata and data formats used in API requests and responses.
| Term / Syntax | Name | Description | Example |
|---|---|---|---|
Content-Type |
Representation Type | Describes the media type of the content being sent. | Content-Type: application/json |
Accept |
Preferred Response Type | Tells the server which response media types the client can handle. | Accept: application/json |
Authorization |
Credentials | Sends credentials used to authenticate a request. | Authorization: Bearer <token> |
JSON.stringify() |
Serialize to JSON | Converts a JavaScript value to a JSON string. | body: JSON.stringify({ name: "Jennifer" }) |
response.json() |
Parse JSON Response | Reads a response body as JSON and returns a Promise with the parsed data. | const data = await response.json(); |
Fetch & Async Requests
Browser APIs and patterns for making asynchronous HTTP requests.
| Term / Syntax | Name | Description | Example |
|---|---|---|---|
fetch() |
HTTP Request | Starts a network request and returns a Promise for a Response. | const response = await fetch("/api/users"); |
async |
Async Function | Allows a function to use await and always returns a Promise. | async function loadUsers() { } |
await |
Await Promise | Waits for a Promise and returns its fulfilled value. | const response = await fetch(url); |
response.ok |
Success-Range Check | true when the response status is in the 200–299 range. |
if (!response.ok) throw new Error(`HTTP ${response.status}`); |
try...catch |
Request Error Handling | Handles errors thrown while awaiting a request or processing its response. | try { await fetch(url); } catch (error) { console.error(error); } |
AbortController |
Cancel Request | Provides a signal that can abort fetch and other supported operations. | const controller = new AbortController(); fetch(url, { signal: controller.signal }); |
CORS |
Cross-Origin Policy | HTTP-header mechanism controlling whether browser code can access cross-origin responses. | Access-Control-Allow-Origin: https://example.com |