Example.
var request = require('request');
var url = "http://localhost:3000";
var requestData = {
...
}
var data = {
url: url,
json: true,
body: JSON.stringify(requestData)
}
request.post(data, function(error, httpResponse, body){
console.log(body);
});
As inserting json: true
option,
sets body to JSON representation of value and adds "Content-type": "application/json"
header. Additionally, parses the response body as JSON.
LINK