2016-03-31 15 views
1

ユーザーデータ全体ではなく、サーバー端末に[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

+1

http://stackoverflow.com/questions/10729276/how-can-i-get-the-full-object-in-node-js-console-log-rather-than-object – cl3m

+0

こちらをご覧ください文字列とオブジェクトを連結するときには、 'console.log("ユーザーはログインチェックの形でユーザ ")を実行してください。 – adeneo

+0

javascriptオブジェクトの' toString'が '' [object Object]」と評価されます' – Akshay

答えて

4

、それを試してみてください

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

と私たちのために結果を書き込みます。

+0

{helpsterId:1、 ファーストネーム: 'ビル'、 姓: 'ゲイツ'、 携帯電話:9560644561、 メール:'[email protected] '、 encryptedPassword:' $ 2a $ 10 $ gezlHKlHZniBugT4MhXlDeWm1yR6S656eMIssTxssGcoh4A/HbZKu '、 性別:'男性 '、 オンライン:真、 管理者:真、 生年月日: '2012-03-20T18:30:00.000Z'、 } –

+0

ユーザーは「( –

+0

どうもありがとうbudyログインチェック[オブジェクトのオブジェクト]を形成しますユーザーフォームのログインチェック "+ user.firstname); ' –

関連する問題