Skip to content

Response Status Codes

Before you hand over the package, you need to declare its condition. This is the HTTP Status Code. It’s not just for errors—it’s the driver’s log of exactly what happened.

Holographic shipping manifest checklist showing 200 OK (Loaded), 300 Redirect (Rerouting), 404 Not Found, and 500 System Error.

Fig 1: The Manifest. Everything accounted for.

  • 2xx (Success): Everything is smooth sailing.
    • 200 OK: Standard success.
    • 201 Created: New resource made (like after a database insert).
  • 3xx (Redirects): The resource moved. Rerouting.
    • 301 Moved Permanently: It’s gone forever, update your bookmarks.
    • 302 Found: Temporary detour.
  • 4xx (Client Error): You messed up.
    • 400 Bad Request: You sent bad data.
    • 401 Unauthorized: Who are you? (Login needed)
    • 403 Forbidden: I know who you are, but you can’t come in.
    • 404 Not Found: Lost map.
  • 5xx (Server Error): We messed up.
    • 500 Internal Server Error: The truck exploded on the way.

Express defaults to 200 if you don’t say anything. But if something goes wrong, or if you need to redirect traffic, you must be explicit.

// 301 Redirect (Moved permanently to the /things lane)
// Useful for SEO when you change URL structures
app.get('/old-things', (req, res) => {
res.redirect(301, '/things');
});
// 404 Not Found (Manual)
app.get('/hidden-bunker', (req, res) => {
res.status(404).send('File Not Found. Checked behind the couch. Nothing.');
});

Express Status Codes - Demo Repo

MDN Status Codes

⏭ Heavy Freight

Sending text is easy. What about sending entire files?