DEV Community

christian0125
christian0125

Posted on

Answer: How can I re-call API in case of axios intercepter error

After some days of investigating my code, I finally found the answer.

Let me write my code and hope it will be helpful.


let refreshToken
if (tokenParts.exp > now) {
            try {
                if (!refreshToken) {
                    refreshToken = service.post('/authentication/token/refresh/', {refresh: refresh_token}).then(token => {
                        refreshToken = null;
                        return token;
                    });
                }

Top comments (0)