title: Why Am getting the request-body content as empty?
body: <p>when i submit the register form ,the data from that register page should be posted on the console.. and I try to print that result using "req.body.Username" , it says undefined and when i view the req in console. The body seems to be an empty set like " {} ", how to post my form details in body to view in console and how to get rid of that "undefined" error?</p>
  
  <p><strong>app.js</strong></p>
  
  <pre><code>const express = require('express');
  const flash = require('connect-flash');
  const path = require('path');
  const request = require('request')
  const expressValidator = require('express-validator');
  const authRoutes = require('./routes/auth-routes');
  const session = require('express-session');
  const passport = require('passport');
  const bodyParser = require('body-parser');
  const mysql = require('mysql');
  const db = require('./config/db');
  const registerc = require('./registerc');
  const loginc = require('./loginc');
  const registerRoute = require('./routes/register');
  const fs = require('fs');
  
  // const request = require('./modules/module1')
  const app = express();
  
  // set view engine
  app.set('view engine', 'pug');
  
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: false }));
  // set up routes
  app.use('/auth', authRoutes);
  app.use('', registerRoute);
  
  // create home route
  app.get('/', (req, res) =&gt; {
              res.render('home');
              res.render('mycourses', {
                  final1: final1
              });
              res.render('recent', {
                  final2: final2
              });
          });
  
  
  // fetching course details
  
  request(options, function (error, response, result) {
      if (error) throw new Error(error);
      // console.log(result);
      // final1 = JSON.stringify(result)
      final1 = JSON.parse(result);
      // console.log(final1);
  });
  
  // fetching User recent Activity
  
  request(options, function (error, response, result) {
      if (error) throw new Error(error);
      // console.log(result);
      final2 = JSON.parse(result);
      // console.log(final2);
      //   console.log(final2.length)
  });
  
  app.use(session(
      {
          secret : 'secret',
          saveUninitialised : true,
          resave : true
      }
  ));
  
  app.use(passport.initialize());
  app.use(passport.session());
  
  
  app.use(expressValidator({
      errorFormatter: function(param, msg, value) {
          var namespace = param.split('.')
          , root    = namespace.shift()
          , formParam = root;
  
        while(namespace.length) {
          formParam += '[' + namespace.shift() + ']';
        }
        return {
          param : formParam,
          msg   : msg,
          value : value
        };
      }
  }));
  
  app.use(flash());    
  
  // app.use(function(res,req,next){
  //  res.locals.success_msg = req.flash('success_msg');
  //  res.locals.error_msg = req.flash('error_msg');
  //  res.locals.error = req.flash('error');
  //  next();
  // })
  
  // app.post('/api/register',registerc.register);
  // app.post('/api/login', loginc.login);
  
  
  
  app.listen(3000, () =&gt; {
      console.log('app now listening for requests on port 3000');
  });
  </code></pre>