我从nodejs的邮递员那里发了一个请求,作为nodejs的初学者,我发现调试.Can很难,有人能解释一下吗?这里是这个时间点的整个存储库。https://github.com/kolaveridi/socialnetwork
router.get('/handle/:handle', (req, res) => {
console.log('working');
console.log(req.params.handle);
const errors = {};
Profile.findOne({ handle: req.params.handle })
.populate('user', ['name', 'avatar'])
.then(profile => {
if (!profile) {
errors.noprofile = 'There is no profile for this user';
console.log('no profile');
res.status(404).json(errors);
}
res.json(profile);
})
.catch(err => res.status(404).json(err));
});
我看不到任何控制台在发送此请求时,我已经有一个用户与“妈妈”注册,登录。http://localhost:5000/api/profile/handle/:mom
发布于 2018-06-03 00:39:42
问题不在于源代码本身,而在于你用来测试应用程序的api url。":“仅在"handle”路由声明中需要,但在url中需要跳过它:
http://localhost:5000/api/profile/handle/mom
关于这个问题:您可以使用console.log和内置调试器(节点检查server.js),也可以使用集成开发环境调试器。
https://stackoverflow.com/questions/50658435
复制相似问题