getStaticProps is not working
Unanswered
hmm_69 posted this in #help-forum
hmm_69OP
I am trying Next js and following Docs but here data is not rendered in the home page
The api endpoints is working fine
import Image from "next/image";
export async function getStaticProps() {
const res = await fetch("http://localhost:3001/api/blogs", { mode: "cors" });
const data = await res.json();
return { props: { data } };
}
export default function Home({ data }) {
return <main>{data}</main>;
}The api endpoints is working fine
7 Replies
hmm_69OP
cors is allowed on all routes
hmm_69OP
I think the issue is I am using app router instead of page router
@hmm_69 I think the issue is I am using app router instead of page router
Correct; app router doesn’t have getStaticProps
@joulev Correct; app router doesn’t have getStaticProps
hmm_69OP
do u guys prefer app router over page ?
Yes I do
hmm_69OP
ok