How to send integers in query parameters in nodejs Express service

前端 未结 4 1171
春和景丽
春和景丽 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:16

    You can't, as HTTP has no notion of types: everything is a string, including querystring parameters.

    What you'll need to do is to use the req.query object and manually transform the strings into integers using parseInt():

    req.query.someProperty = parseInt(req.query.someProperty);
    

提交回复
热议问题