我在 Next.js API 路由中使用 Prisma (4.2.1) 进行基于光标的帖子分页。
当我将光标传递到 API 端点时,我在控制台中收到以下错误消息 (500):
TypeError: Cannot read properties of undefined (reading 'createdAt')
at getPost (webpack-internal:///(api)/./lib/api/post.ts:67:46)
error - TypeError [ERR_INVALID_ARG_TYPE]: The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received an instance of TypeError
Run Code Online (Sandbox Code Playgroud)
我正在使用 Postman 访问 API 端点。
当我从 API 路由中删除光标时,没有错误并且帖子按预期返回。
我尝试升级到最新的 Prisma 版本(4.2.1),在光标上使用 .toString() ,并将 AllPosts 接口更改为“any”,但我无法解决 TypeError。
如何修复此错误并使 Prisma 接受光标有效?
TypeError: Cannot read properties of undefined (reading 'createdAt')
at getPost (webpack-internal:///(api)/./lib/api/post.ts:67:46)
error …Run Code Online (Sandbox Code Playgroud)