Stop 23 · Interview PreparationTechnical · 7/8

HTTP methods and status codes

Part of the Frontend Developer Roadmap

In short

These often come up as quick-fire questions: 'What's 401 vs 403?', 'When do you get a 304?'. They're easy marks if you've revised, and awkward silences if you haven't.

Fluent, fast recall of what GET/POST/PUT/PATCH/DELETE mean and what the common status code ranges (2xx/3xx/4xx/5xx) signal — frequently tested as quick-fire questions.

The jaadu security guard at an office front desk holds up a polite hand to a visitor.

Think of it like this

The office building security desk

No ID card? 'Sorry, who are you?' (401). ID card, but this floor isn't yours? 'You can't go in' (403). Asking for a room that doesn't exist? 'No such room' (404). The lift is broken? 'Our problem, not yours' (500).

Watch it happen

401 vs 403 vs 201

Browser
Server

GET /admin (no token)

1/6No login cookie or token is sent. The server doesn't know who you are.

The big ideas

What you need to know

2xx: it worked

200 OK, 201 Created (after a POST), 204 No Content (success with no body).

3xx: look elsewhere

301 moved permanently, 302 moved temporarily, 304 not modified (use your cached copy).

4xx: the request was wrong

400 bad input, 401 not logged in, 403 not allowed, 404 not found, 409 conflict, 429 too many requests.

5xx: the server failed

500 internal error, 502 bad gateway, 503 service unavailable. Not the user's fault.

See it in code

Walk through the code

js
1function messageFor(status) {2  if (status === 401) return "Please log in again.";3  if (status === 403) return "You don't have access to this.";4  if (status === 404) return "We couldn't find that.";5  if (status === 409) return "Someone else changed this. Refresh and try again.";6  if (status === 429) return "Too many tries. Wait a minute.";7  if (status >= 500) return "Something broke on our side. Try again soon.";8  if (status >= 400) return "Please check what you entered.";9  return "";10}

1/4401: not logged in, so ask the user to log in again.

A tiny map from status codes to friendly messages. Mentioning that you show different UI for 401 (redirect to login) and 403 (no access) shows real-world experience.

Save yourself the pain

Common mistakes

Oops

Mixing up 401 and 403.

Do this instead

401 means 'we don't know who you are'. 403 means 'we know who you are, and the answer is no'.

Oops

Building an API that returns 200 with { error: true } for failures.

Do this instead

Use proper 4xx and 5xx codes, so tools, caches and the frontend can react correctly.

Your mission

Flashcard sprint

~15 min

Quick check

A logged-in student tries to open the admin-only page. Which status should the API return?

Go deeper

  1. 1Make a flashcard set of common status codes (200, 201, 204, 301, 400, 401, 403, 404, 500) and drill them.
  2. 2Practice explaining the difference between 401 and 403 precisely.
  3. 3Know which methods are idempotent and which aren't.

More technical at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge