尝试使用knex将用户存储到psql db中时,如何解决“无法读取未定义的属性查询”

我正在尝试使用OAuth2 Passportjs策略使用Google Auth。我既无法检查数据库中的现有用户,也无法将新用户保存到数据库中。使用Google登录后,似乎我没有得到回复,或者我的查询有问题。

我尝试了async / await语法,我尝试了console.log应该由Google发回的配置文件对象,并且console.log没有显示。

passport.use (
  new GoogleStrategy (
    {
      clientID: keys.googleclientID,clientSecret: keys.googleclientSecret,callbackURL: '/auth/google/callback',},async (accessToken,refreshToken,profile,done) => { 
      const existingUser = await knex('users').where({googleId: profile.id}).returning('*').then(data =>{
        return data;
      })
      const userParams = {googleId: profile.id}

      if(existingUser){
        done(null,existingUser)
      } else {
        knex ('users').insert(userParams).returning("*").then(data => {
          res.send(data)
        })
      }

每次调用回调时,都会出现TypeError: Cannot read property 'query' of undefined错误

hanpangzi2234 回答:尝试使用knex将用户存储到psql db中时,如何解决“无法读取未定义的属性查询”

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3139984.html

大家都在问