【发布时间】:2020-12-04 02:08:31
【问题描述】:
在 IndexPage 上,我正在使用 getStaticProps 调用 api。当我在前端 console.log 时,我在浏览器上得到一个空对象。
我正在使用 NextJS
const IndexPage = (props) => {
console.log(props)
return(
<h1>Hello</h1>
)
}
export async function getStaticProps() {
const res = await fetch("https://jsonplaceholder.typicode.com/todos");
const posts = await res.json();
return {
props: {
posts,
},
};
}
export default IndexPage;
【问题讨论】:
标签: javascript reactjs next.js server-side-rendering