I am trying to fetch data from an Api but for sorry i've received this Error:
Server Error
Error: Error serializing .results returned from getServerSideProps in "/".
Reason: undefined cannot be serialized as JSON. Please use null or omit this value.
The props you're passing contain an object with a key of value undefined. A quick solution would be
return {
props: {
results: JSON.parse(JSON.stringify(request.results));
}
}
JSON.stringify will remove those undefined values. You can try it out in your browser console: JSON.stringify({someKey:undefined})