【发布时间】:2021-05-18 11:00:40
【问题描述】:
大家好,我对打字稿中的类型有疑问。 我正在使用 micro orm 从我正在使用此代码的数据库中获取数据
const user = (await orm).em.findOne(User, { username: options.username });
它回来了
user: Promise<string | null>
我的问题从这里开始我必须将此对象用作表单中的字符串
user.password
在以下查询中
const valid = await argon2.verify(user.password ,options.password);
但它给了我错误
Property 'password' does not exist on type 'Promise<User | null>'
我不知道如何解决这个问题
【问题讨论】:
-
你的函数是返回
Promise<string | null>还是Promise<User | null>?顺便说一句,这些都没有password的属性。
标签: javascript typescript react-fullstack micro-orm