Axios:暂停请求

I have the following axios interceptor.

It checks the validity of the stored token. If not valid, a request is fired to retrieve and store the refreshed token.

axios.interceptors.request.use(async config =>

    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;
}); 

It works great. The problem is that if I have many requests with invalid token then many requests to http://foobar.com/auth/refresh are done to refresh it.

Is it possible to put all the requests in an array and fire them after when the refresh is done ?

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.