Automating access token refreshing via interceptors in axios












2














We've recently discussed an axios' interceptor for OAuth authentication token refresh in this question.



Basically, what the interceptor should do is to intercept any response with 401 status code and try to refresh the token.
With that in mind, the next thing to do is to return a Promise from the interceptor, so that any request which would have normally fail, would run as nothing happens after a token refresh.



The main problem is, that an interceptor checks only the 401 status code, which is not enough, as the refreshToken will also return 401 status code when it fails - and we have a loop.



There are two possible scenarios I have in mind:




  1. check the called URL, so if that's /auth/refresh it shouldn't try to refresh the token;

  2. omit an interceptor when the refreshToken logic is called


The first option looks a bit "not dynamic" to me. The second option looks promising, but I'm not sure if it's event possible.



The main question is then, how can we differentiate/identify calls in an interceptor and run different logic for them without "hardcoding" it specifically, or is there any way to omit the interceptor for a specified call? Thank you in advance.



The code for an interceptor might help to understand the question:





Axios.interceptors.response.use(response => response, error => {
const status = error.response ? error.response.status : null

if (status === 401) {
// will loop if refreshToken returns 401
return refreshToken(store).then(_ => {
error.config.headers['Authorization'] = 'Bearer ' + store.state.auth.token;
error.config.baseURL = undefined;
return Axios.request(error.config);
})
// Would be nice to catch an error here, which would work, if the interceptor is omitted
.catch(err => err);
}

return Promise.reject(error);
});


and token refreshing part:



function refreshToken(store) {
if (store.state.auth.isRefreshing) {
return store.state.auth.refreshingCall;
}

store.commit('auth/setRefreshingState', true);
const refreshingCall = Axios.get('get token').then(({ data: { token } }) => {
store.commit('auth/setToken', token)
store.commit('auth/setRefreshingState', false);
store.commit('auth/setRefreshingCall', undefined);
return Promise.resolve(true);
});

store.commit('auth/setRefreshingCall', refreshingCall);
return refreshingCall;
}









share|improve this question





























    2














    We've recently discussed an axios' interceptor for OAuth authentication token refresh in this question.



    Basically, what the interceptor should do is to intercept any response with 401 status code and try to refresh the token.
    With that in mind, the next thing to do is to return a Promise from the interceptor, so that any request which would have normally fail, would run as nothing happens after a token refresh.



    The main problem is, that an interceptor checks only the 401 status code, which is not enough, as the refreshToken will also return 401 status code when it fails - and we have a loop.



    There are two possible scenarios I have in mind:




    1. check the called URL, so if that's /auth/refresh it shouldn't try to refresh the token;

    2. omit an interceptor when the refreshToken logic is called


    The first option looks a bit "not dynamic" to me. The second option looks promising, but I'm not sure if it's event possible.



    The main question is then, how can we differentiate/identify calls in an interceptor and run different logic for them without "hardcoding" it specifically, or is there any way to omit the interceptor for a specified call? Thank you in advance.



    The code for an interceptor might help to understand the question:





    Axios.interceptors.response.use(response => response, error => {
    const status = error.response ? error.response.status : null

    if (status === 401) {
    // will loop if refreshToken returns 401
    return refreshToken(store).then(_ => {
    error.config.headers['Authorization'] = 'Bearer ' + store.state.auth.token;
    error.config.baseURL = undefined;
    return Axios.request(error.config);
    })
    // Would be nice to catch an error here, which would work, if the interceptor is omitted
    .catch(err => err);
    }

    return Promise.reject(error);
    });


    and token refreshing part:



    function refreshToken(store) {
    if (store.state.auth.isRefreshing) {
    return store.state.auth.refreshingCall;
    }

    store.commit('auth/setRefreshingState', true);
    const refreshingCall = Axios.get('get token').then(({ data: { token } }) => {
    store.commit('auth/setToken', token)
    store.commit('auth/setRefreshingState', false);
    store.commit('auth/setRefreshingCall', undefined);
    return Promise.resolve(true);
    });

    store.commit('auth/setRefreshingCall', refreshingCall);
    return refreshingCall;
    }









    share|improve this question



























      2












      2








      2


      1





      We've recently discussed an axios' interceptor for OAuth authentication token refresh in this question.



      Basically, what the interceptor should do is to intercept any response with 401 status code and try to refresh the token.
      With that in mind, the next thing to do is to return a Promise from the interceptor, so that any request which would have normally fail, would run as nothing happens after a token refresh.



      The main problem is, that an interceptor checks only the 401 status code, which is not enough, as the refreshToken will also return 401 status code when it fails - and we have a loop.



      There are two possible scenarios I have in mind:




      1. check the called URL, so if that's /auth/refresh it shouldn't try to refresh the token;

      2. omit an interceptor when the refreshToken logic is called


      The first option looks a bit "not dynamic" to me. The second option looks promising, but I'm not sure if it's event possible.



      The main question is then, how can we differentiate/identify calls in an interceptor and run different logic for them without "hardcoding" it specifically, or is there any way to omit the interceptor for a specified call? Thank you in advance.



      The code for an interceptor might help to understand the question:





      Axios.interceptors.response.use(response => response, error => {
      const status = error.response ? error.response.status : null

      if (status === 401) {
      // will loop if refreshToken returns 401
      return refreshToken(store).then(_ => {
      error.config.headers['Authorization'] = 'Bearer ' + store.state.auth.token;
      error.config.baseURL = undefined;
      return Axios.request(error.config);
      })
      // Would be nice to catch an error here, which would work, if the interceptor is omitted
      .catch(err => err);
      }

      return Promise.reject(error);
      });


      and token refreshing part:



      function refreshToken(store) {
      if (store.state.auth.isRefreshing) {
      return store.state.auth.refreshingCall;
      }

      store.commit('auth/setRefreshingState', true);
      const refreshingCall = Axios.get('get token').then(({ data: { token } }) => {
      store.commit('auth/setToken', token)
      store.commit('auth/setRefreshingState', false);
      store.commit('auth/setRefreshingCall', undefined);
      return Promise.resolve(true);
      });

      store.commit('auth/setRefreshingCall', refreshingCall);
      return refreshingCall;
      }









      share|improve this question















      We've recently discussed an axios' interceptor for OAuth authentication token refresh in this question.



      Basically, what the interceptor should do is to intercept any response with 401 status code and try to refresh the token.
      With that in mind, the next thing to do is to return a Promise from the interceptor, so that any request which would have normally fail, would run as nothing happens after a token refresh.



      The main problem is, that an interceptor checks only the 401 status code, which is not enough, as the refreshToken will also return 401 status code when it fails - and we have a loop.



      There are two possible scenarios I have in mind:




      1. check the called URL, so if that's /auth/refresh it shouldn't try to refresh the token;

      2. omit an interceptor when the refreshToken logic is called


      The first option looks a bit "not dynamic" to me. The second option looks promising, but I'm not sure if it's event possible.



      The main question is then, how can we differentiate/identify calls in an interceptor and run different logic for them without "hardcoding" it specifically, or is there any way to omit the interceptor for a specified call? Thank you in advance.



      The code for an interceptor might help to understand the question:





      Axios.interceptors.response.use(response => response, error => {
      const status = error.response ? error.response.status : null

      if (status === 401) {
      // will loop if refreshToken returns 401
      return refreshToken(store).then(_ => {
      error.config.headers['Authorization'] = 'Bearer ' + store.state.auth.token;
      error.config.baseURL = undefined;
      return Axios.request(error.config);
      })
      // Would be nice to catch an error here, which would work, if the interceptor is omitted
      .catch(err => err);
      }

      return Promise.reject(error);
      });


      and token refreshing part:



      function refreshToken(store) {
      if (store.state.auth.isRefreshing) {
      return store.state.auth.refreshingCall;
      }

      store.commit('auth/setRefreshingState', true);
      const refreshingCall = Axios.get('get token').then(({ data: { token } }) => {
      store.commit('auth/setToken', token)
      store.commit('auth/setRefreshingState', false);
      store.commit('auth/setRefreshingCall', undefined);
      return Promise.resolve(true);
      });

      store.commit('auth/setRefreshingCall', refreshingCall);
      return refreshingCall;
      }






      vue.js oauth oauth-2.0 axios interceptor






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 14 '18 at 6:31

























      asked Aug 2 '18 at 6:28









      Dawid Zbiński

      1,39922337




      1,39922337
























          2 Answers
          2






          active

          oldest

          votes


















          2





          +50









          I may have found a way much simpler to handle this : use axios.interceptors.response.eject() to disable the interceptor when I call the /api/refresh_token endpoint, and re-enable it after.



          The code :



          createAxiosResponseInterceptor() {
          const interceptor = axios.interceptors.response.use(
          response => response,
          error => {
          // Reject promise if usual error
          if (errorResponse.status !== 401) {
          return Promise.reject(error);
          }

          /*
          * When response code is 401, try to refresh the token.
          * Eject the interceptor so it doesn't loop in case
          * token refresh causes the 401 response
          */
          axios.interceptors.response.eject(interceptor);

          return axios.post('/api/refresh_token', {
          'refresh_token': this._getToken('refresh_token')
          }).then(response => {
          saveToken();
          error.response.config.headers['Authorization'] = 'Bearer ' + response.data.access_token;
          return axios(error.response.config);
          }).catch(error => {
          destroyToken();
          this.router.push('/login');
          return Promise.reject(error);
          }).finally(createAxiosResponseInterceptor);
          }
          );
          }





          share|improve this answer































            1














            Not sure if this suits your requirements or not, but another workaround could also be the separate Axios Instances (using axios.create method) for refreshToken and the rest of API calls. This way you can easily bypass your default interceptor for checking the 401 status in case of refreshToken.



            So, now your normal interceptor would be the same.



            Axios.interceptors.response.use(response => response, error => {
            const status = error.response ? error.response.status : null

            if (status === 401) {
            // will loop if refreshToken returns 401
            return refreshToken(store).then(_ => {
            error.config.headers['Authorization'] = 'Bearer ' + store.state.auth.token;
            error.config.baseURL = undefined;
            return Axios.request(error.config);
            })
            // Would be nice to catch an error here, which would work, if the interceptor is omitted
            .catch(err => err);
            }

            return Promise.reject(error);
            });


            And, your refreshToken would be like:



            const refreshInstance = Axios.create();

            function refreshToken(store) {
            if (store.state.auth.isRefreshing) {
            return store.state.auth.refreshingCall;
            }

            store.commit('auth/setRefreshingState', true);
            const refreshingCall = refreshInstance.get('get token').then(({ data: { token } }) => {
            store.commit('auth/setToken', token)
            store.commit('auth/setRefreshingState', false);
            store.commit('auth/setRefreshingCall', undefined);
            return Promise.resolve(true);
            });

            store.commit('auth/setRefreshingCall', refreshingCall);
            return refreshingCall;
            }


            here are some nice links [1] [2], you can refer for Axios Instances






            share|improve this answer





















            • I think it would work, but is it worth creating another instance of axios? I appreciate you took the time to write down the answer, but I'll wait a while, as someone might have the single-instance answer. Anyways, thank you.
              – Dawid Zbiński
              Nov 14 '18 at 6:27











            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51646853%2fautomating-access-token-refreshing-via-interceptors-in-axios%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2





            +50









            I may have found a way much simpler to handle this : use axios.interceptors.response.eject() to disable the interceptor when I call the /api/refresh_token endpoint, and re-enable it after.



            The code :



            createAxiosResponseInterceptor() {
            const interceptor = axios.interceptors.response.use(
            response => response,
            error => {
            // Reject promise if usual error
            if (errorResponse.status !== 401) {
            return Promise.reject(error);
            }

            /*
            * When response code is 401, try to refresh the token.
            * Eject the interceptor so it doesn't loop in case
            * token refresh causes the 401 response
            */
            axios.interceptors.response.eject(interceptor);

            return axios.post('/api/refresh_token', {
            'refresh_token': this._getToken('refresh_token')
            }).then(response => {
            saveToken();
            error.response.config.headers['Authorization'] = 'Bearer ' + response.data.access_token;
            return axios(error.response.config);
            }).catch(error => {
            destroyToken();
            this.router.push('/login');
            return Promise.reject(error);
            }).finally(createAxiosResponseInterceptor);
            }
            );
            }





            share|improve this answer




























              2





              +50









              I may have found a way much simpler to handle this : use axios.interceptors.response.eject() to disable the interceptor when I call the /api/refresh_token endpoint, and re-enable it after.



              The code :



              createAxiosResponseInterceptor() {
              const interceptor = axios.interceptors.response.use(
              response => response,
              error => {
              // Reject promise if usual error
              if (errorResponse.status !== 401) {
              return Promise.reject(error);
              }

              /*
              * When response code is 401, try to refresh the token.
              * Eject the interceptor so it doesn't loop in case
              * token refresh causes the 401 response
              */
              axios.interceptors.response.eject(interceptor);

              return axios.post('/api/refresh_token', {
              'refresh_token': this._getToken('refresh_token')
              }).then(response => {
              saveToken();
              error.response.config.headers['Authorization'] = 'Bearer ' + response.data.access_token;
              return axios(error.response.config);
              }).catch(error => {
              destroyToken();
              this.router.push('/login');
              return Promise.reject(error);
              }).finally(createAxiosResponseInterceptor);
              }
              );
              }





              share|improve this answer


























                2





                +50







                2





                +50



                2




                +50




                I may have found a way much simpler to handle this : use axios.interceptors.response.eject() to disable the interceptor when I call the /api/refresh_token endpoint, and re-enable it after.



                The code :



                createAxiosResponseInterceptor() {
                const interceptor = axios.interceptors.response.use(
                response => response,
                error => {
                // Reject promise if usual error
                if (errorResponse.status !== 401) {
                return Promise.reject(error);
                }

                /*
                * When response code is 401, try to refresh the token.
                * Eject the interceptor so it doesn't loop in case
                * token refresh causes the 401 response
                */
                axios.interceptors.response.eject(interceptor);

                return axios.post('/api/refresh_token', {
                'refresh_token': this._getToken('refresh_token')
                }).then(response => {
                saveToken();
                error.response.config.headers['Authorization'] = 'Bearer ' + response.data.access_token;
                return axios(error.response.config);
                }).catch(error => {
                destroyToken();
                this.router.push('/login');
                return Promise.reject(error);
                }).finally(createAxiosResponseInterceptor);
                }
                );
                }





                share|improve this answer














                I may have found a way much simpler to handle this : use axios.interceptors.response.eject() to disable the interceptor when I call the /api/refresh_token endpoint, and re-enable it after.



                The code :



                createAxiosResponseInterceptor() {
                const interceptor = axios.interceptors.response.use(
                response => response,
                error => {
                // Reject promise if usual error
                if (errorResponse.status !== 401) {
                return Promise.reject(error);
                }

                /*
                * When response code is 401, try to refresh the token.
                * Eject the interceptor so it doesn't loop in case
                * token refresh causes the 401 response
                */
                axios.interceptors.response.eject(interceptor);

                return axios.post('/api/refresh_token', {
                'refresh_token': this._getToken('refresh_token')
                }).then(response => {
                saveToken();
                error.response.config.headers['Authorization'] = 'Bearer ' + response.data.access_token;
                return axios(error.response.config);
                }).catch(error => {
                destroyToken();
                this.router.push('/login');
                return Promise.reject(error);
                }).finally(createAxiosResponseInterceptor);
                }
                );
                }






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 14 '18 at 8:57









                Dawid Zbiński

                1,39922337




                1,39922337










                answered Nov 14 '18 at 6:30









                Ismoil Shifoev

                1,226711




                1,226711

























                    1














                    Not sure if this suits your requirements or not, but another workaround could also be the separate Axios Instances (using axios.create method) for refreshToken and the rest of API calls. This way you can easily bypass your default interceptor for checking the 401 status in case of refreshToken.



                    So, now your normal interceptor would be the same.



                    Axios.interceptors.response.use(response => response, error => {
                    const status = error.response ? error.response.status : null

                    if (status === 401) {
                    // will loop if refreshToken returns 401
                    return refreshToken(store).then(_ => {
                    error.config.headers['Authorization'] = 'Bearer ' + store.state.auth.token;
                    error.config.baseURL = undefined;
                    return Axios.request(error.config);
                    })
                    // Would be nice to catch an error here, which would work, if the interceptor is omitted
                    .catch(err => err);
                    }

                    return Promise.reject(error);
                    });


                    And, your refreshToken would be like:



                    const refreshInstance = Axios.create();

                    function refreshToken(store) {
                    if (store.state.auth.isRefreshing) {
                    return store.state.auth.refreshingCall;
                    }

                    store.commit('auth/setRefreshingState', true);
                    const refreshingCall = refreshInstance.get('get token').then(({ data: { token } }) => {
                    store.commit('auth/setToken', token)
                    store.commit('auth/setRefreshingState', false);
                    store.commit('auth/setRefreshingCall', undefined);
                    return Promise.resolve(true);
                    });

                    store.commit('auth/setRefreshingCall', refreshingCall);
                    return refreshingCall;
                    }


                    here are some nice links [1] [2], you can refer for Axios Instances






                    share|improve this answer





















                    • I think it would work, but is it worth creating another instance of axios? I appreciate you took the time to write down the answer, but I'll wait a while, as someone might have the single-instance answer. Anyways, thank you.
                      – Dawid Zbiński
                      Nov 14 '18 at 6:27
















                    1














                    Not sure if this suits your requirements or not, but another workaround could also be the separate Axios Instances (using axios.create method) for refreshToken and the rest of API calls. This way you can easily bypass your default interceptor for checking the 401 status in case of refreshToken.



                    So, now your normal interceptor would be the same.



                    Axios.interceptors.response.use(response => response, error => {
                    const status = error.response ? error.response.status : null

                    if (status === 401) {
                    // will loop if refreshToken returns 401
                    return refreshToken(store).then(_ => {
                    error.config.headers['Authorization'] = 'Bearer ' + store.state.auth.token;
                    error.config.baseURL = undefined;
                    return Axios.request(error.config);
                    })
                    // Would be nice to catch an error here, which would work, if the interceptor is omitted
                    .catch(err => err);
                    }

                    return Promise.reject(error);
                    });


                    And, your refreshToken would be like:



                    const refreshInstance = Axios.create();

                    function refreshToken(store) {
                    if (store.state.auth.isRefreshing) {
                    return store.state.auth.refreshingCall;
                    }

                    store.commit('auth/setRefreshingState', true);
                    const refreshingCall = refreshInstance.get('get token').then(({ data: { token } }) => {
                    store.commit('auth/setToken', token)
                    store.commit('auth/setRefreshingState', false);
                    store.commit('auth/setRefreshingCall', undefined);
                    return Promise.resolve(true);
                    });

                    store.commit('auth/setRefreshingCall', refreshingCall);
                    return refreshingCall;
                    }


                    here are some nice links [1] [2], you can refer for Axios Instances






                    share|improve this answer





















                    • I think it would work, but is it worth creating another instance of axios? I appreciate you took the time to write down the answer, but I'll wait a while, as someone might have the single-instance answer. Anyways, thank you.
                      – Dawid Zbiński
                      Nov 14 '18 at 6:27














                    1












                    1








                    1






                    Not sure if this suits your requirements or not, but another workaround could also be the separate Axios Instances (using axios.create method) for refreshToken and the rest of API calls. This way you can easily bypass your default interceptor for checking the 401 status in case of refreshToken.



                    So, now your normal interceptor would be the same.



                    Axios.interceptors.response.use(response => response, error => {
                    const status = error.response ? error.response.status : null

                    if (status === 401) {
                    // will loop if refreshToken returns 401
                    return refreshToken(store).then(_ => {
                    error.config.headers['Authorization'] = 'Bearer ' + store.state.auth.token;
                    error.config.baseURL = undefined;
                    return Axios.request(error.config);
                    })
                    // Would be nice to catch an error here, which would work, if the interceptor is omitted
                    .catch(err => err);
                    }

                    return Promise.reject(error);
                    });


                    And, your refreshToken would be like:



                    const refreshInstance = Axios.create();

                    function refreshToken(store) {
                    if (store.state.auth.isRefreshing) {
                    return store.state.auth.refreshingCall;
                    }

                    store.commit('auth/setRefreshingState', true);
                    const refreshingCall = refreshInstance.get('get token').then(({ data: { token } }) => {
                    store.commit('auth/setToken', token)
                    store.commit('auth/setRefreshingState', false);
                    store.commit('auth/setRefreshingCall', undefined);
                    return Promise.resolve(true);
                    });

                    store.commit('auth/setRefreshingCall', refreshingCall);
                    return refreshingCall;
                    }


                    here are some nice links [1] [2], you can refer for Axios Instances






                    share|improve this answer












                    Not sure if this suits your requirements or not, but another workaround could also be the separate Axios Instances (using axios.create method) for refreshToken and the rest of API calls. This way you can easily bypass your default interceptor for checking the 401 status in case of refreshToken.



                    So, now your normal interceptor would be the same.



                    Axios.interceptors.response.use(response => response, error => {
                    const status = error.response ? error.response.status : null

                    if (status === 401) {
                    // will loop if refreshToken returns 401
                    return refreshToken(store).then(_ => {
                    error.config.headers['Authorization'] = 'Bearer ' + store.state.auth.token;
                    error.config.baseURL = undefined;
                    return Axios.request(error.config);
                    })
                    // Would be nice to catch an error here, which would work, if the interceptor is omitted
                    .catch(err => err);
                    }

                    return Promise.reject(error);
                    });


                    And, your refreshToken would be like:



                    const refreshInstance = Axios.create();

                    function refreshToken(store) {
                    if (store.state.auth.isRefreshing) {
                    return store.state.auth.refreshingCall;
                    }

                    store.commit('auth/setRefreshingState', true);
                    const refreshingCall = refreshInstance.get('get token').then(({ data: { token } }) => {
                    store.commit('auth/setToken', token)
                    store.commit('auth/setRefreshingState', false);
                    store.commit('auth/setRefreshingCall', undefined);
                    return Promise.resolve(true);
                    });

                    store.commit('auth/setRefreshingCall', refreshingCall);
                    return refreshingCall;
                    }


                    here are some nice links [1] [2], you can refer for Axios Instances







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 14 '18 at 5:01









                    waleed ali

                    313214




                    313214












                    • I think it would work, but is it worth creating another instance of axios? I appreciate you took the time to write down the answer, but I'll wait a while, as someone might have the single-instance answer. Anyways, thank you.
                      – Dawid Zbiński
                      Nov 14 '18 at 6:27


















                    • I think it would work, but is it worth creating another instance of axios? I appreciate you took the time to write down the answer, but I'll wait a while, as someone might have the single-instance answer. Anyways, thank you.
                      – Dawid Zbiński
                      Nov 14 '18 at 6:27
















                    I think it would work, but is it worth creating another instance of axios? I appreciate you took the time to write down the answer, but I'll wait a while, as someone might have the single-instance answer. Anyways, thank you.
                    – Dawid Zbiński
                    Nov 14 '18 at 6:27




                    I think it would work, but is it worth creating another instance of axios? I appreciate you took the time to write down the answer, but I'll wait a while, as someone might have the single-instance answer. Anyways, thank you.
                    – Dawid Zbiński
                    Nov 14 '18 at 6:27


















                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51646853%2fautomating-access-token-refreshing-via-interceptors-in-axios%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    鏡平學校

                    ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

                    Why https connections are so slow when debugging (stepping over) in Java?