node.jsexpressroutes

Still wondering how to get Express to ignore matching route


I have this verbatim:

router.get('/top_level_questions,', function (req, res) {
      res.json({success:true});
});


router.get('/:id', function (req, res) {
      res.json({success:true});
});

what's happening is that a request to

/top_level_questions

will match the /:id handler. What is the official way to prevent that from happening>


Solution

  • The code:

    router.get('/top_level_questions,', function (req, res) {
          res.json({success:true});
    });
    

    Should be:

    router.get('/top_level_questions', function (req, res) {
          res.json({success:true});
    });