问题
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