I am testing a server.js file through curl from cmd for post request where I am getting the above error. I saw many related question and answers but nothing solves my problem. Please provide me the solution.
This is my server.js
var app = require('express')();
var bodyParser = require('body-parser');
app.use(bodyParser.json()); // for parsing application/json
app.post('/data', function (req, res) {
console.log(req.body);
res.end();
});
app.listen(3000);
and This is curl code from cmd,
C:\Users\user\Downloads\Compressed\curl.exe -d '{"key1":"value1", "key2":"value2"}' -H "Content-Type: application/json" -X POST http://localhost:3000/data
This is the error I am getting,