title: How to use body-parser in express router?
body: <p>I have a post api that has object but i am not able to print in console its throowing undefined i thought i am missing body-parser but after adding body parser i see error <code>body-parser deprecated bodyParser: use individual json/urlencoded middlewares</code> Any help will be appreciated.</p>
  
  <p>routes.js</p>
  
  <pre><code>var express = require('express');
  var bodyParser = require('body-parser');
  var Diagram = require('./api/diagram/diagram.controller');
  var router = express.Router();
  router.post('/saveUpdateDiagram',bodyParser,function(req,res){
      console.log(req.body);
  });
  </code></pre>
  
  <p>app.js</p>
  
  <pre><code>var express = require('express');
  var path = require('path');
  var app = express();
  var bodyParser = require('body-parser');
  var router = express.Router();
  var route = require('./server/routes').router;
  var mongoose = require('mongoose');
  mongoose.connection.on('connected', function() {
      console.log('MongoDB connected ');
  });
  
  
  app.use(express.static(path.join(__dirname, 'public')));
  app.use('/', route);
  app.use(bodyParser.urlencoded({
      extended: false
  }))
  app.use(bodyParser.json())
  
  
  app.listen(8760, function() {
      console.log('I am listening 8760...');
  });
  </code></pre>