title: Express nodejs not inserting data using mongoose with form-data
body: <p>From last 2 weeks i am unable to post a data to insert into database using form-data it always shows 400 bad request here is my code
  My <strong>server.js</strong> </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>require('./db.js')
  let express = require('express')
  // let mongoose = require()
  const app = express()
  const path = require('path')
  let routes = require('./routes');
  const bodyParser = require('body-parser')
  app.set('port', 4000);
  
  // app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({extended:false}))
  
  app.use('/api', routes);
  
  
  app.use(function(req, res, next){
      console.log(req.method, req.url);
      next();
  })
  
  let server = app.listen(app.get('port'), function(){
      let port = server.address().port;
      console.log("Connected Successfully at", + port);
  });</code></pre>
  </div>
  </div>
  
   here is my <strong>Controller</strong> file code</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>let mongoose = require('mongoose');
  let cat = mongoose.model('Cat')
  
  
  module.exports.addcat = function(req, res){
      console.log(req.body);
      cat.
          create({
          cat_name: req.body.cat_name,
          cat_description: req.body.cat_description
  
      },function(err, cate){
          if(err){
              console.log(" Error creating Hotel");
              res
                  .status(400)
                  .json(err)
          }else{
              console.log("Hotel created", cate);
              res
                  .status(200)
                  .json(cate);
          }
      })
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>Here is my schema file shop.models.js</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>let mongoose = require('mongoose')
  
  let productSchema = new mongoose.Schema({
      prod_name : {
          type:String,
          required:true
      },
      prod_description : {
          type:String,
          required:true
      },
      prod_base_price : {
          type:Number,
          required:true
      },
      prod_tax : {
          type:Number,
          required:true
      },
      prod_final_price : {
          type:Number,
          required:true
      },
      prod_images : [Array],
      prod_discount : {
          type:Number,
          required:true
      }
  
  })
  
  let catSchema = new mongoose.Schema({
      cat_name:{
          type:String,
          required:true
      },
      cat_description:{
          type:String,
          required:true
      }
  })
  
  
  mongoose.model("Cat", catSchema);</code></pre>
  </div>
  </div>
  </p>
  
  <p>this my routes file routes.js</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const express = require('express')
  const router = express.Router();
  const ctrlCat = require('../controllers/cat.controller.js')
  
  
  
  // Category Router
  router
      .route('/cat')
      .get(ctrlCat.getcat)
      .post(ctrlCat.addcat);
  
  router
      .route('/cat/:catid')
      .get(ctrlCat.getonecat)
      .put(ctrlCat.editonecat)
      .delete(ctrlCat.deletecat);
  
  module.exports = router;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Please help me to out always shows this error </p>
  
  <pre><code>{
      "errors": {
          "cat_name": {
              "message": "Path `cat_name` is required.",
              "name": "ValidatorError",
              "properties": {
                  "message": "Path `{PATH}` is required.",
                  "type": "required",
                  "path": "cat_name"
              },
              "kind": "required",
              "path": "cat_name",
              "$isValidatorError": true
          },
          "cat_description": {
              "message": "Path `cat_description` is required.",
              "name": "ValidatorError",
              "properties": {
                  "message": "Path `{PATH}` is required.",
                  "type": "required",
                  "path": "cat_description"
              },
              "kind": "required",
              "path": "cat_description",
              "$isValidatorError": true
          }
      },
      "_message": "Cat validation failed",
      "message": "Cat validation failed: cat_name: Path `cat_name` is required., cat_description: Path `cat_description` is required.",
      "name": "ValidationError"
  }
  </code></pre>
  
  <p>and 400 bad request i am unable to understand where m doing wrong please help me out m stuck here from last 2 weeks When ever i send my data using form-data it show this error other wise it working fine with urlencoded and raw. Currently m testing over postman. I tried this with react too but shows same issue</p>