useSWR returning undefined data #1662
Replies: 5 comments 8 replies
-
Does https://swr.vercel.app/docs/options const { isValidating } = useSWR(key, fetcher)
return isValidation && <Loading /> |
Beta Was this translation helpful? Give feedback.
-
So how do I deal with this problem? |
Beta Was this translation helpful? Give feedback.
-
I had the same problem earlier this week. After hours of troubleshooting, I realised I didn't do a good job with error handling on the API side. I was returning a string instead of JSON. My fetcher response was also Verify that the API in |
Beta Was this translation helpful? Give feedback.
-
Never mind, I found my error that, in the page, I should use const { data, error } = useSWR(
user ? `/api/user/${user.uid}` : null,
fetcher
); Too stupid me. 🙃 |
Beta Was this translation helpful? Give feedback.
-
@FlorjanKlancar Did you manage to fix this? I'm having the same issue |
Beta Was this translation helpful? Give feedback.
-
Hello everyone, my app is returning undefined data if I render my pages with Next/link hook... If I reload that exact same page the data is correct and defined! If I click through an app via Next/link hooks the data keeps being undefined resulting in thrown error.
What do I need to do to render loading if data is undefined and not throw an error...?
Beta Was this translation helpful? Give feedback.
All reactions