-
Notifications
You must be signed in to change notification settings - Fork 91
Description
I've configured two instances of Axios, each config with its createAuthRefreshInterceptor to manage token refresh. these Axios instances interact with distinct servers, yet both servers employ the same authentication mechanism. However, I've encountered a scenario where both Axios instances are invoked simultaneously within a single useEffect hook. This results in concurrent token refresh requests using the same refresh token. While the first API call successfully refreshes the token, the second one fails and else logic executed
createAuthRefreshInterceptor(axios1, refreshTokenWrapper)
createAuthRefreshInterceptor(axios2, refreshTokenWrapper)
I want the token refresh process to be initiated only once in response to a 401 error across multiple instance APIs. Subsequent failed API calls should wait for the token refresh to complete before retrying, instead of triggering additional refresh requests
is there any way to achieve this?