axios-auth-refresh
axios-auth-refresh copied to clipboard
multiple axios instance. don't need to reqeuest refresh api multiple times
what i use:
createAuthRefreshInterceptor(instance, refreshAuthLogic, { statusCodes: [401, 403], pauseInstanceWhileRefreshing : true })

but have a situation. my project have multiple axios instance. so i use 'axios-auth-refresh' library. when api interface 401 or 403, mean token expired. so multiple axios will issue refresh api interface to get new token and new refresh token. by the way, in my project , refresh api interface need a params of refreshToken,and refreshToken only can use one time, if use more than one time, refresh api interface will append error.
so in multiple axios instance situation, the token expired and multiple axios instance request at the same time.
i use 'axios-auth-refresh' library, every axios instance will request refresh api, use the same refreshToken params. but only first request normal, the others request error, because refreshToken can only be use one time.
createAuthRefreshInterceptor(instance, refreshAuthLogic, { statusCodes: [401, 403], pauseInstanceWhileRefreshing : true })
and i think, in multiple axios instance, in fact, refreshAuthLogic function don't need to call refresh api multi time. only one time is ok. is better, right?
i fix it in the way. but is not better. i think 'axios-auth-refresh' can Encapsulate this functionality