Replies: 1 comment
-
Looks like your response is not a JSON but an HTML, check in your browser Network tab the actual response you are receiving from the server. |
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.
-
It works fine when I use axios:
const response = await Axios.get("/mock-api/mockItem"); //response.data has expected response
When I try the same trivial case with SWR:
const { data, error } = useSWR("/mock-api/mockItem");
It gets stuck in the loading state.
I tried passing a simple fetch function (in case that is needed) like:
and now I get "SyntaxError: Unexpected token < in JSON at position 0"
I'm probably making some dumb error, I know, but none of the examples are helping, they just confuse me more.
Beta Was this translation helpful? Give feedback.
All reactions