HTTP and JSON: The Language Servers Speak
Requests, responses, status codes, headers, and JSON โ the vocabulary behind every fetch call you have written.
The request, dissected
GET /courses/web-development-beginner HTTP/1.1
Host: codejourney.example
Accept: application/json
- Method โ the verb:
GET(read),POST(create/submit),PUT/PATCH(update),DELETE(remove) - Path โ which resource
- Headers โ metadata (what formats are accepted, who is calling)
The response, dissected
HTTP/1.1 200 OK
Content-Type: application/json
{"id": "web-development-beginner", "lessons": 62}
A status code, headers, and a body. The families:
- 1xx informational ยท 2xx success ยท 3xx redirect
- 4xx the client's mistake (
404not found,401unauthenticated,403forbidden,429too many requests) - 5xx the server's mistake
You have met several already: Code Journey's run API answers 401 when you
are signed out and 429 when you exceed the rate limit โ now you can read
those like a professional.
JSON: the data format of the web
JSON (JavaScript Object Notation) is text shaped like JavaScript objects โ objects, arrays, strings, numbers, booleans, null. Every language reads it, which is why APIs everywhere speak it:
const text = '{"user":{"name":"Ada","roles":["learner"]}}';
const data = JSON.parse(text); // string โ object
data.user.roles[0]; // "learner" โ navigate like any object
JSON.stringify(data); // object โ string (for sending)
Stateless โ and why cookies exist
HTTP is stateless: every request arrives alone, remembering nothing. So how do sites keep you logged in? Cookies โ small pieces of data the browser attaches to every request to that site. The server reads the cookie, recognizes your session, and treats the request as yours. That single mechanism is how "stay signed in" works everywhere.
What you learned
- Requests: method + path + headers; responses: status + headers + body
- Status families; the everyday ones (
401,403,404,429) - JSON is the web's data format;
JSON.parse/stringifyconvert - Statelessness โ cookies โ sessions
Next: where the data lives โ databases.