我有这个控制器
Posts.listHashtags = ()=>{
return Post
.aggregate([{$unwind:"$hashtags"},
{$group:{_id:"$hashtags", count:{$sum:1}}},
{$sort:{count:-1}},
{$limit:5},
{$project: {_id:0, hashtags :"$_id", count:"$count"}}
])
.exec()
}
在我的路线中,当我想访问未定义的值时,我在做什么错了?
router.get('/posts/hashtags/', verifyAuth, function (req, res) {
axios.get('http://localhost:3000/api/posts/hashtags/')
.then(resposta => {
console.log('hashtags'+resposta.hashtags)
})
.catch(erro => {
console.log('Error'+erro)
})
});