I'm trying to figure out why my getStaticProps
is not sending any data. When I log the Home page props, it shows posts
as undefined. I'm new to Next.js
Here's my code
export async function getStaticProps() {
const response = await fetch("https://jsonplaceholder.typicode.com/posts/")
const data = response.json()
return {
props: { data },
}
}
export default function Home({ posts }: any) {
console.log(`posts`, posts) // This prints undefined
return (
<main className="wrapper wrapper-aligned-center | flow">
<h1 className="fz-900">Learning NextJS</h1>
</main>
)
}
Your help is greatly appreciated.