Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiple axios instance. don't need to reqeuest refresh api multiple times #210

Open
0zcl opened this issue Oct 11, 2022 · 0 comments
Open

Comments

@0zcl
Copy link

0zcl commented Oct 11, 2022

what i use:
createAuthRefreshInterceptor(instance, refreshAuthLogic, { statusCodes: [401, 403], pauseInstanceWhileRefreshing : true })
image

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?

image
i fix it in the way. but is not better. i think 'axios-auth-refresh' can Encapsulate this functionality

@0zcl 0zcl changed the title multiple axios. don't need to reqeuest refresh api multiple times multiple axios instance. don't need to reqeuest refresh api multiple times Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant