progress-bar-4-axios icon indicating copy to clipboard operation
progress-bar-4-axios copied to clipboard

loading bar doesnt disappear on connection refused

Open ryanm352 opened this issue 5 years ago • 1 comments

When axios encounters a connection refused error, the progress bar doesn't disappear when the request has failed.

ryanm352 avatar Apr 12 '19 14:04 ryanm352

fix:

       setupStopProgress = () => {
        const responseFunc = (response) => {
            if ((--this.requestsCounter) === 0) {
                NProgress.done();
            }
            return response;
        };

        const errorFunc = (error) => {
            return Promise.reject(error).then(this.reset, this.reset);
        };
        this.instance.interceptors.response.use(responseFunc, errorFunc);
    };

    reset() {
        NProgress.remove();
    }

ryanm352 avatar Apr 12 '19 15:04 ryanm352