Closed shtlrs closed 1 year ago
You can pass a function of your choice to the retryCondition
option that checks for error conditions that are specific to your system.
If the status code is 2xx, then I don't think axios-retry is available.
The reason is that axios-retry
implements an interceptor for non-2xx responses, as you can see in the code
The following is taken from axios' README
axios.interceptors.response.use(function (response) {
// Any status code that lie within the range of 2xx cause this function to trigger
// Do something with response data
return response;
}, function (error) {
// Any status codes that falls outside the range of 2xx cause this function to trigger
// Do something with response error
return Promise.reject(error);
});
If you want to implement retry processing in 2xx, I think you need to implement the interceptor by yourself referring to the above instead of using axios-retry
.
Found a similar issue https://github.com/softonic/axios-retry/issues/100 which describes a way to implement a custom interceptor for 2xx responses.
Ok, I see the maintainers don't want to include this behavior since there are workarounds.
I'll be closing this then.
Thanks folks.
I'm consuming a specific API that returns internal codes in the responses. Example:
The thing is, the HTTP request's status code is
200
, which means thatAxiosError
won't be thrown by the client, and thus, my retry condition won't trigger.Is this something that: