//set the global number of requests in main.js, the requested GapAxios.defaults.retry = 4; Axios.defaults.retryDelay= 1000; Axios.interceptors.response.use (Undefined,functionAxiosretryinterceptor (err) {varConfig =Err.config; //If Config does not exist or the retry option was not set, Reject if(!config | |!config.retry)returnPromise.reject (ERR); //Set the variable for keeping track of the retry countConfig.__retrycount = Config.__retrycount | | 0; //Check If we ' ve maxed out the total number of retries if(Config.__retrycount >=config.retry) {//Reject with the error returnPromise.reject (ERR); } //increase the retry countConfig.__retrycount + = 1; //Create new promise to handle exponential backoff varBackoff =NewPromise (function(Resolve) {SetTimeout (function() {resolve (); }, Config.retrydelay|| 1); }); //Return the promise in which recalls Axios to retry the request returnBackoff.then (function() { returnAxios (config); });});
Request Timeout Vue Axios re-request again