I'm fetching data from /api/notes/1 and receive this:
{
"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"
}
Which is fine and dandy, but when I pass it into Next's getStaticProps:
export async function getStaticProps({ params }) {
const res = await fetch(`${config.apiURL}/notes/${params.id}`);
const post = await res.json();
return { props: { post } };
}
It returns an error:
FetchError: invalid json response body at http://localhost:3000/api/notes/1 reason: Unexpected end of JSON input
What's going on here?