pace icon indicating copy to clipboard operation
pace copied to clipboard

Vuejs + Axios didnt work

Open angelmartz opened this issue 7 years ago • 10 comments

Pace.js, dont detect axios call on vuejs 2.0

angelmartz avatar Jul 12 '17 18:07 angelmartz

I am having the same issue. Any news?

the94air avatar Sep 10 '17 13:09 the94air

Me too.

vsg24 avatar Sep 12 '17 11:09 vsg24

#436

the94air avatar Sep 12 '17 15:09 the94air

This was my solution.

var numberOfAjaxCAllPending = 0;
// Add a request interceptor
axios.interceptors.request.use(function (config) {
    numberOfAjaxCAllPending++;
Pace.start()

    return config;
}, function (error) {
    return Promise.reject(error);
});

// Add a response interceptor
axios.interceptors.response.use(function (response) {
    numberOfAjaxCAllPending--;
    // Do something with response data
    if (numberOfAjaxCAllPending == 0) {
          Pace.stop() 
    }
    return response;
}, function (error) {
    numberOfAjaxCAllPending--;
    if (numberOfAjaxCAllPending == 0) {
         Pace.stop() 
    }
    return Promise.reject(error);
});

@the94air @VSG24 @angelmartz

joseboretto avatar Sep 20 '17 03:09 joseboretto

it looks like it is the only way. Thanks @zeditio.

the94air avatar Sep 20 '17 08:09 the94air

Use Pace.start() and Pace.stop() instead.

setefocos avatar Nov 03 '17 20:11 setefocos

thanks @setefocos . I updated the code

joseboretto avatar Nov 04 '17 02:11 joseboretto

@zeditio It looks even better if you use Pace.restart() instead of Pace.start() but it also stop before the end of the actual ajax request.

the94air avatar Nov 10 '17 14:11 the94air

Use : https://github.com/hilongjw/vue-progressbar

berthojoris avatar Nov 17 '17 10:11 berthojoris

You guys experience the progress bar finishing before calling .stop? is there a way around that?

exp0nge avatar Jul 30 '19 03:07 exp0nge