我在我的服務器終端中獲取[object,Object]而不是整個用戶數據。我不知道這是什麼意思......我認爲我做得很完美,但仍然無法獲得全部數據。我指定了sailjs服務器。 如何獲取整個用戶數據而不是[object,Object]?獲取[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
查看http://stackoverflow.com/questions/10729276/how-can-i-get-the-full-object-in-node-js-console-log-rather-than-object – cl3m
這就是你得到的當你連接一個字符串和一個對象時,試着做'console.log(「用戶形成登錄檢查,用戶)'而不是看對象 – adeneo
一個調用javascript對象的'toString'評估爲''[object Object]」 ' – Akshay