所以.我在下一个js中有一个api,它使用Prisma客户端。Prisma是从prisma.ts中定义的全局对象导入的。
在本地,一切都很好地构建和运行。我没有错误,并定义了prisma变量。然而,当它被部署到Vercel时,prisma是个未知数.我不知道为什么。
如果有人有任何建议,我会非常感激的。
import eBayApi from "@hendt/ebay-api";
import prisma from "../../lib/prisma";
const eBay = new eBayApi({});
export default async (req, res) => {
// Access the provided 'page' and 'limt' query parameters
const code = req.query.code; // this is provided from eBay
console.log(code);
try {
//const token = await eBay.OAuth2.getToken(code);
const token = "bob";
console.log("Prisma handler instance", prisma);
const env_variable = await prisma.variable.upsert({
where: {
variable: "EBAY_TOKEN",
},
update: { value: token },
create: {
variable: "EBAY_TOKEN",
value: token,
},
});
if (env_variable) {
console.log("New Token Stored in DB");
} else console.log("Failed to store new Token");
res.status(200);
res.writeHead(302, {
Location: "/orders",
//add other headers here...
});
res.end();
} catch (e) {
console.error(e);
res.status(400).end();
}
res.writeHead(302, {
Location: "/orders",
//add other headers here...
});
res.end();
};exports.modules.5712.webpack_exports.default (/var/task/nextjs-store/.next/server/pages/api/success.js:55:126) 2021-04-18T19:06:18.680Z 869eb228-423a-4d6a-b05a-f95f5e843c88错误TypeError:无法读取在processTicksAndRejections上未定义的属性“93”(内部/进程/任务队列,93:93:5)/server/api-utils.js:8:1)在异步的(/var/task/nextjs-store/node_modules/next/dist/next-server/server/next-server.js:67:462)上,在异步的Server.handleApiRequest,在异步的Object.fn,在异步的Object.fn,在异步的Router.execute (/var/task/nextjs-store/node_modules/next/dist/next-server/server/异步服务器上的异步(/var/task/nextjs-store/node_modules/next/dist/next-server/server/next-server.js:69:1042) (异步(/var/task/nextjs-store/node_modules/next/dist/next-server/server/next-server.js:34:504) )。(/var/task/nextjs-store/___next_launcher.js:26:9)
发布于 2021-04-27 07:52:19
所以,我玩了一个游戏,认为我发现了问题。我的prisma表字段是一个VARCHAR (String),但是我无意中试图用JSON对象存储新插入。现在,我已经更改为一个JSON字段,它正在工作。
所以我想唯一的问题是也许这个错误不是helpul?虽然这都是我愚蠢的错。
https://stackoverflow.com/questions/67152459
复制相似问题