retry after an async call
hello
im trying to implement a refresh token flow with react query
when I encounter a 401 i want to make a call to get a new token and swap it THEN retry. any ideas on how to pull this off leveraging what query gives me or should i go custom(keep it outside of query)
2 Replies
ratty-blush•4y ago
we usually recommend to handle auth on the actual network layer - axios or fetch or whatever you are using. I was thinking about maybe making retries async (https://github.com/TanStack/query/discussions/2770), there is nothing that speaks against this apart from how to design the api, but there wasn't much demand apart from refetching auth tokens in there
GitHub
async retry · Discussion #2770 · TanStack/query
HI, in my old project I was making an Axios interceptor and queuing all failed requests then fetch and refresh my refreshToken then retry all the failed requests. with React Query I don't n...
mute-goldOP•4y ago
thanks !