正在获取[对象,对象],而不是整个用户数据.这是什么意思

Getting [object, Object] instead of whole user data. What does that mean?

本文关键字:对象 用户数 用户 数据 意思 是什么 获取      更新时间:2023-10-25

我正在服务器终端中获取[object,object],而不是整个用户数据。我不知道那是什么意思。。。我认为我做得很完美,但仍然无法获得全部数据。我指定了sailjs服务器。如何获取整个用户数据而不是[对象,对象]?

module.exports = {
  /**
   * Check the provided email address and password, and if they
   * match a real user in the database, sign in to Medool.
   */
  login: function (req, res) {
    // Try to look up user using the provided email address
    User.findOne({
      email: req.param('email')
    }, function foundUser(err, user) {
      if (err)
        return res.negotiate(err);
      if (!user)
        return res.notFound();
      // Compare password attempt from the form params to the encrypted password
      // from the database (`user.password`)
      require('machinepack-passwords').checkPassword({
        passwordAttempt: req.param('password'),
        encryptedPassword: user.encryptedPassword
      }).exec({
        error: function (err) {
          return res.negotiate(err);
        },
        /*
         If the password from the form params doesn't checkout w/ the encrypted
         password from the database...
         */
        incorrect: function () {
          return res.notFound();
        },
        success: function () {
          // Store user id in the user session
          console.log("User form the login check" +user)
          req.session.me = user.helpsterId;
          console.log(req.session.me);
          // All done- let the client know that everything worked.
          return res.ok();
        }
      });
    });
  }
};

当提升的服务器是控制台中的[object,object]时的输出

试试吧,

console.log(user);
console.log(JSON.stringify(user));
console.log("User form the login check" +user);

并为我们编写结果。