I am trying to modify the body of GET request. For that I tried this:
function modify(req, res, next){
res.body = res.body "modified";
next();
}
then when I try to log req.body it prints nothing
Ref: Connect or Express middleware to modify the response.body
CodePudding user response:
You can not use body for GET requests.
request body of GET request will always be undefined.
To pass some values along with GET request you can pass it in query parameters.
CodePudding user response:
To retrieve values from GET method you need to used 'req.params' followed by the name of parameter.
for exemple 'req.params.id'