我在我的服务器终端中获取 [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();
}
});
});
}
};
最佳答案
试试吧,
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/