title: BodyParser Express, I've got Object inside Object
body: <p>I am trying post some data on a server but doesn't work because I am getting something like { '{\n        "rate" : "26"\n}': '' }. </p>
  
  <p>----App.js  </p>
  
  <pre><code>const express     = require('express'),
        mongoose    = require('mongoose'),
        bodyParser  = require('body-parser');
  
  const db            = mongoose.connect('mongodb://localhost/invoiceAPI');
        app           = express(),
        port          = process.env.PORT || 3000,
        Rate          = require('./models/rateModel'),
        Client        = require('./models/clientModel'),
        Invoice       = require('./models/invoiceModel');
  
  app.use(bodyParser.urlencoded({extended: true}));
  app.use(bodyParser.json());
  
  const invoiceRouter = require('./routes/invoiceRoutes')(Invoice),
        clientRouter  = require('./routes/clientRoutes')(Client),
        rateRouter    = require('./routes/rateRoutes')(Rate);
  
  app.use('/api/invoices', invoiceRouter);
  app.use('/api/clients', clientRouter);
  app.use('/api/rates', rateRouter);
  
  app.listen(port, () =&gt; {
      console.log('Gulp is running on port ' + port);
  });
  </code></pre>
  
  <p>---The rateRoutes file:</p>
  
  <pre><code>const express = require('express');
  
  const rateRoutes = (Rate) =&gt; {
      const rateRouter = express.Router();
  
      rateRouter.route('/')
        .get((req,res) =&gt; {
            Rate.find((err,rates) =&gt; {
              if(err){
                res.status(500).send(err);
              }
              else res.json(rates);
            });
        })
        .post((req,res) =&gt; {
          console.log(req.body);
          let rate = new Rate(req.body);
          rate.save();
          res.status(201).send(rate);
        });
      return rateRouter;
  }
  
  module.exports = rateRoutes;
  </code></pre>
  
  <p>When I execute the post with {"rate": 26} I got 
  { '{\n        "rate" : "26"\n}': '' }</p>
  
  <p>I read something about the order of bodyParser, but doesn't work.</p>