Member-only story
How to Specify statusCode in Node.js
What is HTTP response status codes?
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
- Informational responses (1xx) — request has been received and the process is continuing.
- Successful responses (2xx) — action was successfully received, understood, and accepted.
- Redirects (3xx) — further action must be taken in order to complete the request.
- Client errors (4xx) — request contains incorrect syntax or cannot be fulfilled.
- Server errors (5xx) — server failed to fulfill an apparently valid request.
The followings are some common ones
- 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. - 404 — it means the file not found, which mean the URL is not recognized.
- 505 — some kind of internal server error and it does not know how to handle.
Complete Node.js articles: