title: Axios Request Interceptor wait until ajax call finishes
body: <p>I have an request interceptor for axios calls. It checks my jwt token and call for refresh if necessary.</p>
  
  <pre><code>axios.interceptors.request.use((config) =&gt;{
  
      const state = store.getState(); // get renewed state
      const time = Math.floor( new Date().getTime() / 1000 );
  
      if( 
          ! state.app.jwtRefreshOnRequest 
          &amp;&amp; time &gt;= state.jwt.expires - 120
          &amp;&amp; state.jwt.refresh_before &gt; time
      ){ // expiring in 2 min. refresh    
  
          //dispatch({type: 'JWT_REFRESH_REQUEST'});
          axios.get( API_BASE_URL + '/auth/refresh')
              .then(function(response){
                  // dispatch({type: 'JWT_REFRESH_SUCCESS', payload: response.data});
                  axios(config).then(resolve, reject);
              })
              .catch(function(err){               
                  reject(err);
          });
  
      }       
  
      return config;
  }); 
  </code></pre>
  
  <p>This code calls the refresh correctly and saves the new token but the original call doesn't holds until the interceptor request is done, so the expired token is used.</p>
  
  <p>So, I guess I need to make synchronous call from interceptor. </p>