How to access body in express.js GET request?

有些话、适合烂在心里 提交于 2021-01-27 17:30:50

问题


I am sending body in GET request in sails.js framework which internally uses express.js

curl -u username:password -i -H "Accept: application/json" -X GET -d "msisdn=32323" http://localhost:9000/api/v1.1/buy/voucher/raj/32323

i am trying to get the value of msisdn in req.body of express but it is giving me undefined.

I read on internet and it says we can send body in GET request. You can refer this stackoverflow thread. HTTP GET with request body


回答1:


With Express it's not possible to send a body with a GET request. http://expressjs.com/en/api.html#req.body.

In reality, you shouldn't even want this Specification. If you want to send data with your GET request, query parameters will suffice, if you have the need to send data securely you shouldn't even want to use a GET request in the first place.



来源:https://stackoverflow.com/questions/37339715/how-to-access-body-in-express-js-get-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!