DEV Community

Discussion on: 404 status code! Really?

Collapse
 
blessanm86 profile image
Blessan Mathew

Was getting bit by this recently and Im also a bit confused on the right approach. There is the spec that everyone keeps talking about. But from a FE perspective, there is so many times I do these kinda GET apis, where I show or hide UI based on the response.

When the server sends 404, it goes into my generic error handling code. Now I need to write conditions there to tell it to ignore this 404 cause my UI knows how to render this response.

I would have preferred the server return 2xx for these situations so that my generic error handling is there to handle actual errors.

Also it creates a lot of noise in the devtools and error tracking tools when you expect certain api's to not have a response.

Maybe something like Axios interceptors will help for my first problem.