我的目标是将登录数据(用户输入)传递给一个函数,在该函数中,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没有得到正确的输入.

推荐答案

在进一步研究后解决了这个问题,我需要后台app.js中的bodyParser

Javascript相关问答推荐

Redux查询多个数据库Api reducerPath&

使搜索栏更改语言

有没有可能使滑动img动画以更快的速度连续?

为什么按钮会随浮动属性一起移动?

实现JS代码更改CSS元素

S文本内容和值不必要的不同

从包含数百行的表中获取更改后的值(以表单形式发送到后端)的正确方法是什么?

如何在ASP.NET JavaScript中使用Google Charts API仅对绘制为负方向的条形图移动堆叠条形图标签位置

如何创建返回不带`new`关键字的实例的类

查询参数中的JAVASCRIPT/REACT中的括号

当标题被点击时,如何使内容出现在另一个div上?

MongoDB受困于太多的数据

第一项杀死下一项,直到数组长度在javascript中等于1

无法使用npm install安装react-dom、react和next

为什么我的SoupRequest";被重置为初始值,以及如何修复它?

有角粘桌盒阴影

检测带有委托的元素内部的点击,以及元素何时按其类名被选中

使用JAVASCRIPT-使用If和Else If多次判断条件-使用JAVASRIPT对象及其属性

我在JS代码中收到超过最大调用堆栈大小的错误,但我找不到原因.有谁能帮我搬一下吗?

Vue3合成API.来自本地存储的对象始终返回UNDEFINED