首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >无法获取节点后端的错误

无法获取节点后端的错误
EN

Stack Overflow用户
提问于 2018-06-08 04:36:00
回答 1查看 146关注 0票数 0

我正在编写我的服务器的后端,我不知道为什么我的代码会给我一个错误。下面是我的代码。

代码语言:javascript
复制
//@routes Get api/profiles/handle/:handle
//@desc Get frofile by handle
//@access public

router.get('/handle/:handle', (req, res) => {
  const error = { };
  Profile.findOne({handle : req.param.handle})
  .populate('user', ['name', 'avatar'])
  .then(profile => {
    if(!profile){
      errors.noprofile= "There is no profile for this user";
      res.status(404).json(errors)
    }

    res.json(profile);
  })
  .catch(err => res.status(404).json(err))
}); 

这是我使用postman得到的url。

http://localhost:5000/api/profiles/handle/sambulo

我得到下面的错误,我不知道哪里出了问题。

代码语言:javascript
复制
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Error</title>
    </head>
    <body>
        <pre>Cannot GET /api/profiles/handle/sambulo</pre>
    </body>
</html>
EN

回答 1

Stack Overflow用户

发布于 2018-06-08 04:50:11

你在路由中有错误。

尝试以下代码:

代码语言:javascript
复制
router.get('/api/profiles/handle/:handle', (req, res) => {
    // Your code here
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50749795

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档