title: axios interceptors to update auth
body: <p>I am using axios interceptors to check auth token on every request. This works fine. But when <code>accessToken</code> is null <code>getToken()</code> is fired twice. Is there a way to wait for the <code>getToken</code> to finish ? I just want <code>getToken</code> to fire once. The other requests needing a token should wait until <code>getToken</code> is fulfilled. </p>
  
  <pre><code>let isAlreadyFetchingAccessTokenRequest = false;
  api.interceptors.request.use(
    async config =&gt; {
      let token = window.localStorage.getItem("accessToken");
  
      if (!isAlreadyFetchingAccessTokenRequest &amp;&amp; !token) {
        isAlreadyFetchingAccessTokenRequest = true;
        token = await getToken();
  
        console.log("1. save token to local storage", token);
        window.localStorage.setItem("accessToken", token);
      }
  
      config.headers.Authorization = `Bearer ${token}`;
      return config;
    },
    function(error) {
      return Promise.reject(error);
    }
  );
  </code></pre>