Skip to content
Discussion options

You must be logged in to vote

A couple of issues I can see.

First you've identified the documentation on https://swr.vercel.app/docs/arguments#multiple-arguments so you've correctly identified that you should be doing something like useSWR(["/user", Cookies.get("jwt")], fetchWithToken) the signature for fetchWithToken would be const fetchWithToken = (url, token) {} when you mention getting "/" and "u" you're doing the equivalent of url[0] and url[1]

Second your fetcher is never returning the promise and you probably shouldn't be catching the error (so you can use const { data, error } = useSWR(...)).

For example this is similar to what I do (you could get rid of the brackes and const fetchWithToken = (url, token) => a…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@TR-Jackson
Comment options

Answer selected by TR-Jackson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants