Why Axios throws exceptions for status code not equal to 200? #5818
Replies: 2 comments 1 reply
-
|
I am also very confused by this. The axios API makes it look at as if you can check the response status code, for example, it looks as if you can do this: However, in practice as the OP as noted, this never happens, and an exception gets thrown. This is very misleading. Or am I missing something? |
Beta Was this translation helpful? Give feedback.
-
|
It's sad to see such an important library changing such an important behavior without proper documentation. This is very much a breaking change, and one I missed because there's no clear docs on the changes from 0.x to 1.x. Now I'm stuck with an old way to handle errors and no clear path as how to fix it, as my application centralizes common errors codes in a single interceptor, and now it seems I also need to I opened an issue to request a docs page on the migration: #7208 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
As in the title of the discussion, why Axios throws exceptions in this way? With this approach, we need to catch each status not equal to 200. Usually, the mapping of status codes for responses should not be handled by the http client. The application should do it. Moreover, Exceptions are really important when developing the application and catching random exceptions makes no sense (always in my opinion). I see this behavior as an abuse of exceptions
Beta Was this translation helpful? Give feedback.
All reactions