title: Axios : put on hold requests
body: <p>I have the following <code>axios</code> interceptor.</p>
  
  <p>It checks the validity of the stored token. If not valid, a request is fired to retrieve and store the refreshed token.</p>
  
  <pre><code>axios.interceptors.request.use(async config =&gt;
  
      if(checkValidity(localStorage.getItem('token')) === false) {
          const response = await axios.get('http://foobar.com/auth/refresh');
          localStorage.setItem('token', response.headers['token']);
          config = getConfigFromResponse(response);
      }
  
      return config;
  }); 
  </code></pre>
  
  <p>It works great. The problem is that if I have many requests with invalid token then many requests to <code>http://foobar.com/auth/refresh</code> are done to refresh it.</p>
  
  <p>Is it possible to put all the requests in an array and fire them after when the refresh is done ?</p>
  
  <p>The idea is to avoid catching 401 errors and replaying the request : this is why I want to "save" the requests while the token is being retrieved and then fire them when the token is ready.</p>