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