javascript - 获取 [object, Object] 而不是整个用户数据。这意味着什么?

标签 javascript sails.js

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

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();
        }
      });
    });

  }

};

Output when lifted server is [object, Object]in console

最佳答案

试试吧,

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

并为我们写下结果。

关于javascript - 获取 [object, Object] 而不是整个用户数据。这意味着什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36342223/

相关文章:

node.js - Sails 生成-oauth

javascript - Angular - 如何取消从后退按钮触发的路由更改?

Javascript - 从链接获取 GET 参数并阻止打开

javascript - React 应用程序中的 addEventListener 不起作用

mongodb - GridFS 和 Sailsjs

javascript - 如何自动解析 Sails.js 路由上的模型属性?

javascript - 使用 iframe 从字符串中获取 src 和其他文本

javascript - 如何在 Joomla 模块后端加载 Javascript 调用?

node.js - 通过 Express 持续更新 Backbone 模型

javascript - 风 sails js : Setting response method based on request parameter