Monday, 24 April 2017

javascript switch statement unexpected token in node.js

below is my route.js, what's wrong with my switch statement?

router.post('/api/profile?:id?:action', (req, res) => {

  switch(req.query.action) {
    case "approve" : {
      return res.json({req.query.action})
      break;
    }

    case "reject" : {
      return res.json({req.query.action})
      break;
    }

    case "delete" : {
      return res.json({req.query.action})
      break;
    }
  }
});

The problem is at

return res.json({req.query.action})

but I don't know why is it so.



via Jay

No comments:

Post a Comment