You must set the request header: Content-Type in the application / json
One thing I want to clarify
req.params is used to get URL parameters
e, g, / user /: name
req.params("name")
And req.param is more powerful , you can get three data using this method with the following priority
e, g, / user /: name
req.param("name")
- Body query string or body data
MAIL TURNOVER (optional, default)
Content-Type:application/json
POST BODY - json data
{'username': 'Chris', 'password': 'mypass'}
OR
POSTAL FACTORY
Content-Type:application/x-www-form-urlencoded
POST BODY - query string
username=Chris&password=mypass
You can use req.param('password') to get the value you sent.
- Query string
e, g, / user? nickname = ryan
req.param("nickname")
source share