When you use :
‘use strict’;
It sets the environment you are in to use strict rules in JavaScript.
when you want to access the body of a HTTP request you need to use a json parser.
// create application/json parser
var jsonParser = bodyParser.json();
// create application/x-www-form-urlencoded parser
var urlencodedParser = bodyParser.urlencoded({
extended: false
});
Then you just need to call the jsonParser variable you made when you make your HTTP request.
router.post(‘/product’, jsonParser, function(req, res)
Now if you log req.body you will be able to view the body.
Postman is a great extension in google chrome that allows you to send HTTP request to servers.