This is my Node Express Code,
(function () {
\'use strict\';
var fs = require(\'fs\');
var cors = require(\'cors\');
var bodyParser = requir
You are posting a plain-text string instead of a JSON. Consider showing us how you are posting data (jQuery, Fetch API, etc).
Just have to specify
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
in your request headers (front-end). The Express body parser should then be able to detect the valid JSON and print the result. Note that Accept isn't required but it instructs the server that the client understands and accepts a JSON response.
Alternatively, use a simple library like Easy Fetch on the front-end to manage server-side calls without having to deal with response parsing or header settings.