我正在使用Prisma和Next.js。当我尝试在
getStaticProps
中从Prisma检索内容时,它确实获取了数据,但我无法将其传递给主组件。export const getStaticProps = async () => {
const prisma = new PrismaClient();
const newsLetters = await prisma.newsLetters.findMany();
console.log(newsLetters);
return {
props: {
newsLetters: newsLetters,
},
};
};
正如您在此图像中所看到的,它正在获取并打印内容。
但是当我将它作为props传递时,会出现以下错误
Reason: `object` ("[object Date]") cannot be serialized as JSON. Please only return JSON serializable data types.