Json中未定义的值数组

Json中未定义的值数组,json,node.js,Json,Node.js,这是我登录用户数据的代码 router.post('/login', function (req, res, next) { /* look at the 2nd parameter to the below call */ let errors = []; if (!req.body.password || !req.body.email) { req.flash('error_msg', 'please enter email and password'); re

这是我登录用户数据的代码

router.post('/login', function (req, res, next) {
  /* look at the 2nd parameter to the below call */
  let errors = [];
  if (!req.body.password || !req.body.email) {
    req.flash('error_msg', 'please enter email and password');
    res.redirect('/login')
  }
  passport.authenticate('local', function (err, user, info) {
    if (err) { return next(err); }
    if (!user) {
      req.flash('error_msg', 'your email or password is not correct');
      res.redirect('/login')
    }
    req.logIn(user, function (err) {
      if (err) { return next(err); }
      var type = user.type;
      var dt = dateTime.create();
      var formatted = dt.format('Y-m-d H:M:S');
      connection.query("update table set last_login = '"+formatted+"' where id = '"+user.id+"'", function (err, rows) {
        if(type == '0'){
          res.redirect('/login');
        }
        else if(type == '1'){
          console.log(user);
          res.cookie('user', user).redirect('/dashboard');
        }
        else{
          res.redirect('/customers');
        }
      });
    });
  })(req, res, next);
});
我试图在node js中控制台一些数据,其中的数据是这样的

{ 
  email: 'test@gmail.com',
  username: 'tester',
  id: 9,
  password: '7ZaOhA0Q0tMTqHC8ExpOLDEdetCb3zKzQYFHIh9RpuI=',
  type: '1',
  token: 
 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7ImVtYWlsIjoic2l2YWFAZ21haWwuY29tIiwidXNlcm5hbWUiOiJzaXZhYSIsImlkIjo5LCJwYXNzd29yZCI6IjdaYU9oQTBRMHRNVHFIQzhFeHBPTERFZGV0Q2Izekt6UVlGSEloOVJwdUk9IiwidHlwZSI6IjEiLCJ0b2tlbiI6IiJ9LCJpYXQiOjE1MzQ1Njg3NjEsImV4cCI6MTUzNDU3MTc2MX0._3AspvfLO2K46OVilqsLtfiRcZTG2ZYvGJWe6jaQ3ZA',
  customers: undefined 
}
现在,我想显示客户字段数据,其中包含像abc、xyz、pqr这样的数据,而且似乎没有定义。 那么,我怎样才能得到数据而不是未定义的数据呢?如果你知道的话,请告诉我未定义值背后的原因


提前感谢您的帮助,让我的日子更美好。

没有看到您的代码,我们如何判断出哪里出了问题好的,我将编辑我的帖子并在您的代码中添加代码,您正在打印
用户。客户
但在响应对象中,您似乎已粘贴
用户
对象,我不确定。。。我说得对吗?我可以看到更新的代码。你能试一下吗。。??请尝试在
passport之后立即打印
user.customers
。验证(…
这一行。并告诉我输出。它必须是
未定义的
。让我们来看看。