vue- unified request processing timeout axio

import axios from 'axios'

// Set the global number of requests, the gap request axios.defaults.retry = 2; axios.defaults.retryDelay = 1000; axios.interceptors.response.use (undefined, function axiosRetryInterceptor (ERR) { var config = err.config; // set the retry or if the config option does not exist, refuse IF (config config.retry ||!!) {$ vux.loading.hide Vue ();. Promise.reject return (ERR)}; // set variable tracking the number of retries config .__ retryCount = config .__ retryCount || 0; // check if the total has reached the maximum number of retries iF (config .__ retryCount> = config.retry) { // VUX going round in circles that hide Vue $. vux.loading.hide (); // throw error return Promise.reject (ERR); } // increase request retries config + = retryCount .__. 1; // Create a new asynchronous request var = new new backoff Promise (function (Resolve) { the setTimeout (function () { Resolve (); }, config.retryDelay ||. 1); }); // return axios information, re-request return backoff.then (function () { Vue $ vux.loading.hide (). ; return Axios (config); }); });

Guess you like

Origin www.cnblogs.com/liuguoying/p/11579627.html