无法获取完整的对象

时间:2019-08-31 06:54:48

标签: javascript node.js mongodb

所以我试图使用Node.js中的API获取配置文件数据,但似乎从未获得完整的对象(例如,响应中缺少头像)

我试图console.log完美运行的对象

这是服务器代码:

router.get('/users/me', auth, async (req, res) => {
    try {
        const me = await User.findById(req.user._id)

        console.log(me)
        res.send(me)
    } catch (e) {
        res.status(500).send(e)
    }
})

这是控制台上的响应:

{ avatar:
   'https://wisapedia-uploads.s3.amazonaws.com/default_ava.png',
  bookmarks: [],
  trips: [],
  verified: false,
  _id: 5d67b4155a032f3450c8ca03,
  name: 'Syauqi',
  password:
   '$2a$08$LwLJPrp6MPdffkpJ1T2iN.QFbMDU5gAsSceNZVzU8tfDe5aUjGfFO',
  email: 'ahmadthariq@gmail.com',
  number: 85786135661,
  birthday: 1997-04-01T16:00:00.000Z,
  tokens:
   [ { _id: 5d67b4155a032f3450c8ca04,
       token:
        'eyJhbGciOiJIUzI1NiIsI4gdCI6IkpXVCJ9.eyJfaWQiOiI1ZDY3YjQxNTVhMDMyZjM0NTBjOGNhMDMiLCJpYXQiOjE1NjcwNzczOTd9.i-r2wB6BoqK7cSoIxBiWB6SSESoCk3S5G_sW5PMz09s' } ],
  createdAt: 2019-08-29T11:16:37.516Z,
  updatedAt: 2019-08-29T11:16:37.572Z,
  __v: 1 }

这就是我对邮递员的看法:

{
    "bookmarks": [],
    "trips": [],
    "verified": false,
    "_id": "5d67b4155a032f3450c8ca03",
    "name": "Syauqi",
    "email": "ahmadthariq@gmail.com",
    "number": 85786135661,
    "birthday": "1997-04-01T16:00:00.000Z",
    "createdAt": "2019-08-29T11:16:37.516Z",
    "updatedAt": "2019-08-29T11:16:37.572Z",
    "__v": 1
}

谢谢

0 个答案:

没有答案