Cho*_*wka 6 javascript json reactjs next.js
我正在从中获取数据/api/notes/1并接收以下内容:
{
"id":1,
"author":1,
"title":"Pierwsza notka",
"excerpt":"Taka tam notka, bla bla bla",
"body":"Pirwsza notka elo",
"private":1,
"created_at":"2021-04-07T12:59:59.000Z",
"updated_at":"2021-04-07T12:59:59.000Z"
}
Run Code Online (Sandbox Code Playgroud)
这很好,但是当我将它传递到 Next 时getStaticProps:
export async function getStaticProps({ params }) {
const res = await fetch(`${config.apiURL}/notes/${params.id}`);
const post = await res.json();
return { props: { post } };
}
Run Code Online (Sandbox Code Playgroud)
它返回一个错误:
FetchError: invalid json response body at http://localhost:3000/api/notes/1 reason: Unexpected end of JSON input
Run Code Online (Sandbox Code Playgroud)
这里发生了什么?
| 归档时间: |
|
| 查看次数: |
13403 次 |
| 最近记录: |