0
ユーザーを自分のアプリケーションにログインさせるカスタムミドルウェアを作成しようとしています。しかし、私は戻って、次のエラーメッセージを取得していますログインしているユーザーを確認してください
async function login(username, password) {
try {
const pwdHash = await bcrypt.hash(password, saltRounds)
const res = await knex("users").where({
username: username,
password: pwdHash
}).first()
console.log("res: " + res) //here I am getting the error
if (res.password == pwdHash) {
return true
} else {
return false
}
} catch (e) {
console.log(e)
}
}
:
TypeError: Cannot read property '0' of undefined
at Object.login (C:\Users\user\project\service\user.js:56:34)
at <anonymous>
を私はすぐにres
オブジェクトにアクセスできないことを知っているが、t
待つshouldn私は、以下の機能を使用しています。このため get an object back. However, I am getting
は未定義です。
私が間違っていることは何ですか?
あなたの返信を歓迎します!