You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using a JWT token in fetcher which refreshes in every 5 minutes. The initial request works as it is expected but when revalidation on focus runs again after 5 minutes, the fetch calls fail because the JWT token inside the revalidating fetch call is not getting refreshed. But when I click and make a new request it works fine again. I am assuming that the fetcher instance is stored initially and the same instance is then used when running revalidation thus the JWT token not being updated.
Example code:
constfetcher=useCallback((url: string)=>{...},[jwt]);const{ data }=useSWRInifinite((index)=>{// returning url with pagination params},fetcher);
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I am using a JWT token in fetcher which refreshes in every 5 minutes. The initial request works as it is expected but when revalidation on focus runs again after 5 minutes, the fetch calls fail because the JWT token inside the revalidating fetch call is not getting refreshed. But when I click and make a new request it works fine again. I am assuming that the fetcher instance is stored initially and the same instance is then used when running revalidation thus the JWT token not being updated.
Example code:
Any idea how I can fix this?
Additional Context
SWR version:
0.3.0-beta.10
Beta Was this translation helpful? Give feedback.
All reactions