Making authenticated calls with useSWR #227
reilly3000
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I wanted desperately to utilize SWR' to make authenticated calls for an analytics dashboard I'm building, but was having a really difficult time finding a way to do in conjunction with next-firebase-auth and useEffect. I was originally trying to get the auth token first, pass it into a fetcher function, then use hooks to pass in the fetcher into useSWR. Instead, composing the fetcher as an inline async function did the trick. Mind you, I'm quite a novice at modern React and front-end state, so this may be obvious to most. I couldn't find a working example elsewhere, so I thought I would share this and hopefully save somebody a few hours:
Beta Was this translation helpful? Give feedback.
All reactions