I've created a very basic express js application. After setting routes and other things I did app.use('/api/', require('./api/api.js'));
api.js looks something like this:
var express = require('express');
var router = express.Router();
router.post('/', function(req, res){
res.end(req.body);
});
module.exports = router;
I'm using Postman chrome extension to post to this route. The response is empty {}
.
The question is: as long as I have in my app.js
body-parser
middleware set do I need to set it again in api.js
? If not why I have an empty response ?
In app.js
body-parser is set like this:
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: false
}));