The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +772K…

Follow publication

Member-only story

How to Specify statusCode in Node.js

Ckmobile
The Startup
Published in
4 min readJan 8, 2021

--

HTTP response status codes allow us to know whether a specific HTTP request has been successfully completed. There are five main classes of response

  1. Informational responses (1xx) — request has been received and the process is continuing.
  2. Successful responses (2xx) — action was successfully received, understood, and accepted.
  3. Redirects (3xx) — further action must be taken in order to complete the request.
  4. Client errors (4xx) — request contains incorrect syntax or cannot be fulfilled.
  5. Server errors (5xx) — server failed to fulfill an apparently valid request.

The followings are some common ones

  1. 200 — everything is OK, the meaning of OK depends on the methods
    GET: The resource has been fetched and is transmitted in the message body.
    HEAD: The entity headers are in the message body.
    PUT or POST: The resource describing the result of the action is transmitted in the message body.
    TRACE: The message body contains the request message as received by the server.
  2. 404 — it means the file not found, which mean the URL is not recognized.
  3. 505 — some kind of internal server error and it does not know how to handle.

Complete Node.js articles:

Part 1: How to create a HTTP server in Node.js

--

--

The Startup
The Startup

Published in The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +772K followers.

Ckmobile
Ckmobile

Written by Ckmobile

Teaching JavasScript, React, React Native, MongoDB and NodeJS https://linktr.ee/ckmobile

No responses yet

Write a response