未验证 提交 7bf7c232 编写于 作者: L Luis Alvarez D 提交者: GitHub

Use getServerSideProps (#11057)

上级 925d8435
......@@ -9,7 +9,7 @@ const Index = ({ people }) => (
</ul>
)
export async function getStaticProps() {
export async function getServerSideProps() {
const response = await fetch('http://localhost:3000/api/people')
const people = await response.json()
......
......@@ -30,20 +30,7 @@ const Person = ({ data, status }) =>
<p>{data.message}</p>
)
export async function getStaticPaths() {
const response = await fetch('http://localhost:3000/api/people')
const data = await response.json()
const paths = data.map(person => ({
params: {
id: person.id,
},
}))
return { paths, fallback: false }
}
export async function getStaticProps({ params }) {
export async function getServerSideProps({ params }) {
const response = await fetch(`http://localhost:3000/api/people/${params.id}`)
const data = await response.json()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册