How to send integers in query parameters in nodejs Express service

前端 未结 4 1163
春和景丽
春和景丽 2020-12-15 04:43

I have a nodejs express web server running on my box. I want to send a get request along with query parameters. Is there any way to find type of each query parameter like in

4条回答
  •  一整个雨季
    2020-12-15 05:24

    Maybe this will be of any help to those who read this, but I like to use arrow functions to keep my code clean. Since all I do is change one variable it should only take one line of code:

    module.exports = function(repo){
    
      router.route('/:id,
      (req, res, next) => { req.params.id = parseInt(req.params.id); next(); })
        .get(repo.getById)
        .delete(repo.deleteById)
        .put(repo.updateById);
    }
    

提交回复
热议问题