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
- Informational responses: 100–199
- Successful responses: 200–299
- Redirects: 300–399
- Client errors: 400–499
- 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