I have the curl command here which is working as I want:
curl -X POST -H "Content-Type: application/json" -d @cats.json http://localhost:8080
And I would like to get help on translating this into nodejs
I currently have localhost set up and my goal is to display data stored in a JSON file. I currently copy and paste the data into postman and post the data to the localhost but I want to not use postman. The curl command was useful but I want to incorporate it into my code.
I've tried
var request = require('request');
request.post({
headers: {'content-type' : 'application/json'},
url: 'http://localhost/8080',
body: "someData"
}, function(error, response, body){
console.log(body);
});
I've tried this but it doesn't provide the same outcome as the curl command does where the data appears in my localhost