Replies: 1 comment
-
@Johncena-Huang did you ever figure this out? im having the same issue |
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.
-
Description:
I’m using
next-auth
withuseSWR
for data fetching, and I'm trying to set up an Axios interceptor to add an Authorization token to the request headers. However, I’m encountering a synchronization issue whereuseSWR
is firing before I reset the axios interceptor(My current approach doesn't work, the sync is fired after useSWR invokes fetcher function).Steps to Reproduce:
useSWR
to fetch data with Axios.Authorization
header with the token fromnext-auth
'suseSession()
.useSWR
is called before the axios interceptor is reset.Code Example:
Global setup
My fetcher
How the fetcher is used
Expected Behavior:
when useSWR calls the fetcher, axios instance interceptor should already be synchronized with useSession. Any approach suggested to handle this issue?
Environment:
Beta Was this translation helpful? Give feedback.
All reactions