无法读取未定义的属性“ getParameters”

时间:2019-04-30 20:58:29

标签: node.js angular typescript express query-builder

我目前正在尝试将前端Ionic应用程序与Node.js后端应用程序连接。应用程序之间的连接之前已经过测试,并且已经部署到Azure(也可以在其中运行)。但是,我正在尝试修复前端中的一个错误,但是当我通过后端用本地数据库查询登录凭据时,我无法登录。

我首先尝试用邮递员打我的后端(localhost:3000 / app / login),其邮寄请求在请求正文中包含电子邮件和密码。

{ email: "email address here", password: "password" }

后端代码正在读取对象,并试图建立查询以在数据库中定位用户。但是,我的查询在某处失败,并且出现错误:

TypeError: Cannot read property 'getParameters' of undefined
    at SelectQueryBuilder.QueryBuilder.createFromAlias (C:\Users\1579639\Desktop\Airline Mobile App\atubsu-airlinecogni-server\src\query-builder\QueryBuilder.ts:546:52)
    at SelectQueryBuilder.from (C:\Users\1579639\Desktop\Airline Mobile App\atubsu-airlinecogni-server\src\query-builder\SelectQueryBuilder.ts:180:32)
    at Object.<anonymous> (C:\Users\1579639\Desktop\Airline Mobile App\atubsu-airlinecogni-server\src\controller\User.ts:24:14)
    at step (C:\Users\1579639\Desktop\Airline Mobile App\atubsu-airlinecogni-server\src\controller\User.ts:32:23)
    at Object.next (C:\Users\1579639\Desktop\Airline Mobile App\atubsu-airlinecogni-server\src\controller\User.ts:13:53)
    at C:\Users\1579639\Desktop\Airline Mobile App\atubsu-airlinecogni-server\src\controller\User.ts:7:71
    at new Promise (<anonymous>)
    at __awaiter (C:\Users\1579639\Desktop\Airline Mobile App\atubsu-airlinecogni-server\src\controller\User.ts:3:12)
    at Object.GetUser [as action] (C:\Users\1579639\Desktop\Airline Mobile App\atubsu-airlinecogni-server\src\controller\User.ts:46:12)
    at C:\Users\1579639\Desktop\Airline Mobile App\atubsu-airlinecogni-server\src\app.ts:27:19
(node:6920) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.

这是我用于查询用户的异步功能。

export async function GetUser(request: Request, response: Response) {
    try {
        console.log(request.body.email);
        const login_query = await getManager().createQueryBuilder()
            .select([
                "user.id",
                "user.email",
                "user.verified_number",
                "user.passenger_",
                "passenger.first_name",
                "passenger.last_name",
                "passenger.dob"
            ])
            .from(Users, "user")
            .leftJoin(Passengers, "passenger", "user.passenger_ = passenger.id")
            .where("user.email = '" + request.body.email + "'")
            .andWhere("user.password = '" + request.body.password + "'")
            .getOne();

        response.send(login_query);
    } catch (error) {
        response.send({ data: 'unsuccessful' });
    }

}

此用于登录的用户查询正在Azure上运行,但是当我在本地进行测试时,我不断收到上述错误。我尝试查找类似的错误,但从未提及属性'getParameters'。这也是我们代码中没有的东西,因此我认为这是某种隐藏的错误。

如果有人知道解决方法,我将不胜感激!

编辑:发布完整错误

0 个答案:

没有答案