Next.js Returning Blank Line or Empty Object from Backend
Last updated: Feb 18, 2022
Hello, I'm working on a local project, trying to return data from sanity. I am building an app with nextjs. I am trying to have nextjs pull data from sanity so it can be rendered server side. I have my request set up, and when I console log the request data it is just a blank line in the console. What am I doing wrong? I can only get it to return an empty object or a blank line. If I set up an async function that isn't doing the next prerender, I get the data returned no problem. What am I doing wrong?
EDIT: Found my problem. I was calling my NextJS function in my component instead of on my page... Moving the logic to the page and passing the data as a prop to the component makes everything work 😅