Replies: 1 comment
-
React Query is not tied to data fetching - it only wants promises. So it also can’t help with anything that’s “Header” specific. This is something your API layer needs to handle. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I’ve been working with React Query and Apollo Client across several projects, but I’ve never really settled on a good strategy for setting the authorization header when using JWT tokens in React Query. I like how Apollo Client handles it with links, but since TanStack Query doesn’t provide anything similar (as far as I know), I’m wondering if there’s a way to achieve something like that without too much extra work.
The main issue I run into is when handling token refresh. If I rely on a custom function to fetch the auth token, multiple simultaneous queries can cause the token refresh logic to run multiple times at once, which isn’t ideal. This does not seem to happen with the auth link in apollo client.
Beta Was this translation helpful? Give feedback.
All reactions