softonic / axios-retry

Axios plugin that intercepts failed requests and retries them whenever possible
Other
1.9k stars 167 forks source link

How to catch/ handle after max reties #112

Open julurivinay opened 4 years ago

julurivinay commented 4 years ago

I want to write a logic after the retry count completed. In axios interceptor i need to write logic for it or do we have any other option for it.

My axios interceptor code looks below const axiosGlobalConfig = function () {

axios.interceptors.request.use(function (config) { console.log('23232', config);

// let configUrl: any = config.url;
// let myRegExp = new RegExp(Config.webServiceUrl, 'i');
// configUrl = configUrl.replace(myRegExp, '');
// config.url = configUrl;

// // config.url;
config.url = Config.webServiceUrl + config.url;

  if (localStorage.getItem('accessToken')) {
  config.headers.Authorization = 'Bearer ' + localStorage.getItem('accessToken');
  config.headers.refreshToken = localStorage.getItem('refreshToken');
  }

  return config;
}, function (error) {
});

axios.interceptors.response.use(function (response) {
 return response;

}, function (error) {

 // console.log('error123', error);
if (error.response == undefined) {
  // console.log('error123', error);
  i = i + 1;
  if(i == 3) {
    alert(i)
  }

}
lukzerom commented 3 years ago

+1 it would be a great feature ;)

Rey-Wang commented 2 years ago

any update on this?

mindhells commented 2 years ago

have a look at #199