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.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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.