Provide option to trigger retry from successful (200) response in Axios's response interceptors
Closed this issue · 4 comments
Reason:
Certain APIs consistently return a 200 HTTP code, with custom error codes embedded within the data payload
Like below
{
"code": -1,
"data":"...",
"msg":"bad request"
}
Please add an option to decide whether to trigger retry from response or error.
axios.interceptors.response.use(function (response) {
return response;
}, function (error) {
return Promise.reject(error);
});
This option is also needed if using a custom validateStatus
function like validateStatus: () => true
. In such a case, the "error" response interceptor is never called (but the "success" one is).
@zhen-one you should be able to use the validateStatus function of axios together with retryCondition to accomplish this.
@zhen-one you should be able to use the validateStatus function of axios together with retryCondition to accomplish this.
apologies, in this case validateStatus
is not enough. I've created a PR for this feature. Would like to hear your (or others') opinion on the usage (see: #272 (comment)) please 🙏
this should be now covered by #272 thanks to @obscurecat64
closing this issue