Skip to main content

HTTP and JSON: The Language Servers Speak

intermediate15 min readLesson 52 of 143

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 (404 not found, 401 unauthenticated, 403 forbidden, 429 too 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/stringify convert
  • Statelessness โ†’ cookies โ†’ sessions

Next: where the data lives โ€” databases.

Now practice

HTTP and JSON: The Language Servers Speak โ€” PracticeHands-on practice for โ€œHTTP and JSON: The Language Servers Speakโ€: apply what you just learned in http-json-apis.1 challenge ยท ยท ~10 min