DEV Community

Cover image for Http Status Codes
Margaret W.N
Margaret W.N

Posted on

Http Status Codes

Sending status codes has become a matter of course in this backend journey. But when do i send a 401 and when do i send a 404?
Today I'll be looking at http status codes. A http status code is a response by the server on the state of a request. Http status codes are divided into 5 major categories

  1. Informational responses: 100–199
  2. Successful responses: 200–299
  3. Redirects: 300–399
  4. Client errors: 400–499
  5. Server errors: 500–599

There's a whole list on each of the categories in MDN and httpstatuses.com.
Here is a list of the status codes I've come across so far.
200 - Ok
201 - Resource Created
204 - No Content
400 - Bad request
401 - Unauthorized
403 - Forbidden. The client is known but has no access rights
404 - Not found
500 - Internal Server error

Having learnt that i adjusted the code to send a 401 when a client is unauthorized. I'll try and use the relevant status codes from now on wards.

End of Day 32

Top comments (4)

Collapse
 
danielyahel profile image
Daniel Yahel

Wow, really liked this index. Wasn't familiar with it before.

Collapse
 
mtee profile image
Margaret W.N

Glad you now have an idea.

Collapse
 
fraybabak profile image
fraybabak

tnx for this article, I think it would be better if we use 422 for database issues such connection issues or any error that comes from db it self

Collapse
 
mtee profile image
Margaret W.N

Okay Fraybabak. I've taken note of that. I'll adjust accordingly thank you.