here is my code for getting data from a graphql query from a headless CMS. It seems though that even though the query is being fetched without error, it creates the "UNEXPECTED END OF JSON INPUT". Occurs when parsing into JSON so I can pass the data to my page.
const URL = process.env.STRAPIBASEURL;
export async function getStaticProps(context) {
const fetchParams = {
method: "posts",
headers: {
"content-type": "application/json",
},
body: JSON.stringify({
query: `{
blogposts{
title
content
slug
img{
url
}
}
}`,
}),
};
const res = await fetch(`${URL}/graphql`, fetchParams);
const data = await res.json();
return {
props: data,
};
}