Currently, I am utilizing Prisma along with Next.js. My issue arises when attempting to retrieve content from Prisma within the getStaticProps
function; while it successfully fetches the data, I encounter difficulties passing it on to the main component.
export const getStaticProps = async () => {
const prisma = new PrismaClient();
const newsLetters = await prisma.newsLetters.findMany();
console.log(newsLetters);
return {
props: {
newsLetters: newsLetters,
},
};
};
Despite displaying the fetched content in this image, an error is generated when trying to pass it as props:
https://i.stack.imgur.com/d34op.png
The error message received states: "Reason: `object` ("[object Date]") cannot be serialized as JSON. Please only return JSON serializable data types."