showing results for - "axios check if call is already running"
Leelou
28 Mar 2018
1var numberOfAjaxCAllPending = 0;
2
3// Add a request interceptor
4axios.interceptors.request.use(function (config) {
5    numberOfAjaxCAllPending++;
6    // show loader
7    return config;
8}, function (error) {
9    return Promise.reject(error);
10});
11
12// Add a response interceptor
13axios.interceptors.response.use(function (response) {
14    numberOfAjaxCAllPending--;
15    console.log("------------  Ajax pending", numberOfAjaxCAllPending);
16
17    if (numberOfAjaxCAllPending == 0) {
18        //hide loader
19    }
20    return response;
21}, function (error) {
22    numberOfAjaxCAllPending--;
23    if (numberOfAjaxCAllPending == 0) {
24        //hide loader
25    }
26    return Promise.reject(error);
27});
28
similar questions
queries leading to this page
axios check if call is already running