Fetching the data from MongoDb in Apps.js is not working #817
-
we tried multiple ways to fetch our data from MongoDB in our app.js. For some reason its not working for us. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Hi there, can you send me a PR to the current status of your project? And do you get any error messages in the console / the terminal? If so, can you also provide them? Thanks in advance ✌️ |
Beta Was this translation helpful? Give feedback.
-
Hi Niklas, Getting Data in the index.js is possible. The uplifting to the _app.js is a problem. We want to retrieve the data in _app.js. The site is turning white and we get no error messages. I think we are trying to get the data before the rendering happens. The page turns white if we put this in:
I think this is an early return, and we give nothing back 😬 That's why the page is turning white. I think we need to store the data. |
Beta Was this translation helpful? Give feedback.
-
For the biggest part, Pete helped us out. ;) We thought it would be enough to wrap it around the components. |
Beta Was this translation helpful? Give feedback.
For the biggest part, Pete helped us out. ;)
We forgot to call the "fetcher". This is correct:
const { data, error, isLoading } = useSWR("/api/places", fetcher);
We thought it would be enough to wrap it around the components.