我的目标是将登录数据(用户输入)传递给一个函数,在该函数中,Prisma在数据库中"搜索"相应的条目.当前代码涉及4个不同的类(不确定它们在此上下文中是否被称为类)
I.Login.jsx接受输入并将其传递给前端API
async function handleLogin() {
const suc = await Api.login(username, password);
}
Ii.Api.ts发送带有此数据的axios POST请求
const url = 'http://localhost:8080';
async function login(username, password) {
console.log(username, password, url);
console.log("Log message of FE-API: " + username);
const response = await axios.post(`${url}/user/login`, {
e_mail: username,
password: password
});
console.log(response);
return response.status === 200;
}
Iii.users.js使用Express js并将数据发布到PrismaApi
router.post('/login', async function (req) {
console.log("Log message of user: " + req);
const loggedIn = await Api.login(req);
res.status(loggedIn ? 200 : 400).send();
})
IV.PrismaApi.js应该使用这些参数来搜索相应的条目
async function login(e_mail) {
console.log("Log message of PrismaApi: " + e_mail);
const loginCreds = await prisma.nutzer.findFirst({
where: {
email: e_mail,
},
});
return !!loginCreds;
}
这条路走错了.
\backend\node_modules\@prisma\client\runtime\index.js:32881
if (!Object.prototype.hasOwnProperty.call(object, key)) {
^
RangeError: Maximum call stack size exceeded
at BufferList.hasOwnProperty (<anonymous>)
at getDepth (D:\(a) Coding\Repositories\b3\backend\node_modules\@prisma\client\runtime\index.js:32881:42)
at getDepth (D:\(a) Coding\Repositories\b3\backend\node_modules\@prisma\client\runtime\index.js:32885:21)
at getDepth (D:\(a) Coding\Repositories\b3\backend\node_modules\@prisma\client\runtime\index.js:32885:21)
at getDepth (D:\(a) Coding\Repositories\b3\backend\node_modules\@prisma\client\runtime\in at getDepth (D:\(a) Coding\Repositories\b3\backend\node_modules\@prisma\client\runtime\index.js:32885:21)
at getDepth (D:\(a) Coding\Repositories\b3\backend\node_modules\@prisma\client\runtime\index.js:32885:21)
at getDepth (D:\(a) Coding\Repositories\b3\backend\node_modules\@prisma\client\runtime\index.js:32885:21)
at getDepth (D:\(a) Coding\Repositories\b3\backend\node_modules\@prisma\client\runtime\index.js:32885:21)
at getDepth (D:\(a) Coding\Repositories\b3\backend\node_modules\@prisma\client\runtime\index.js:32885:21) {
clientVersion: '4.6.1'
}
在同时使用邮箱和密码之前,我仅在邮箱中try 了此代码,以测试工作流程.我期待一个代码来查看登录过程是否成功,但我只收到来自Prisma模块的错误消息,所以我猜Prisma没有得到正确的输入.