I've run into the error below when trying to use getServerSideProps to fetch data from an endpoint.
Error:
ERROR TypeError: res.hasHeader is not a function
at sendPayload (/var/task/pages/posts.js:2120:231)
at renderReqToHTML (/var/task/pages/posts.js:6235:13)
at process._tickCallback (internal/process/next_tick.js:68:7)
Function:
export const getServerSideProps : GetServerSideProps = async () => {
const API = 'http://myAPIEndpoint'
const res = await fetch(API, {
headers: {
'Id': '1234'
}
});
const posts = await res.json()
return{
props: {
posts
}
};
}