Replies: 2 comments
-
2 seconds after posting this ,I happened across this: Which seems like I can override logic for what constitutes an error or not... but I am still interested if there is a better way to handle this |
Beta Was this translation helpful? Give feedback.
-
Are you looking this plugin? https://www.npmjs.com/package/axios-auth-refresh |
Beta Was this translation helpful? Give feedback.
-
Greetings...
I'm working within a very constricted environment and codebase, and have a weird requirement where in some cases we'll get a specific error from our API. In response to this error, I'd like to effectively handle the error, execute other logic, and ultimately return items as expected.
If status code 400 was a regular response (in the context of the interceptor), it'd be easy enough to get status code, run other logic, and ultimately resolve promise with the other data, but is there a way to do that from within response interceptors, onErrror?
I could probably have some layer wrapping, and have catches that ultimately return the same thing, but I'd like developers to be able to effectively be able to get a axios instance with interceptors, and use it as they are expected to after that.
Deeper detail
All I'm hoping to do is be able to do
getSomeAxiosInstance().get(/* usual stuff here */)
(as a side note, I looked into axios-retry... as it kind of seems like what I was hoping to do, except other than retry, I just execute some logic and re-execute the endpoint once)Beta Was this translation helpful? Give feedback.
All reactions