title: How to pass a json object to node js server
body: <p>I want to create a hybrid mobile application where the backend is Node js that it will save data in mongodb my server works properly I prepared routes for handling users requests </p>
  
  <p>I can get data from my server using GET method but my problem that I can't save data that is sended from ionic user interface using POST method. I tried to send   data using POSTMAN the data was saved succesfully in mongodb but the problem occur when I send data from mobile user interface </p>
  
  <p>this is a picture to show the results in node js server of sending POST request using POSTMAN 
  and sending POST request from mobile user interce </p>
  
  <p><a href="https://i.stack.imgur.com/gEQ86.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gEQ86.png" alt="enter image description here"></a></p>
  
  <p>and this how data is saved in mongoDB</p>
  
  <p><a href="https://i.stack.imgur.com/mx4wG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mx4wG.png" alt="enter image description here"></a></p>
  
  <p>this is my routes file in node server </p>
  
  <pre><code>var Product = require('../models/product');
  var express = require('express');
  var router = express.Router();
  
  router.route('/products')
  
  
      .get(function(req, res) {
  
  
        Product.find(function(err, products) {
          if (err) {
            return res.send(err);
          }
  
          res.json(products);
          });
  
  
      })
  
      .post(function(req, res) {
  
  
        console.log(req.body);
  
        var product = new Product(req.body);
  
  
        product.save(function(err) {
          if (err) {
            return res.send(err);
          }
  
          res.send({ message: 'product Added' });
        });
      });
  </code></pre>
  
  <p>this is the form </p>
  
  <pre><code>&lt;label  class="item item-input"&gt;
  
              &lt;input name="1" type="text" ng-model="product.nom" placeholder="nom du produit"&gt;
            &lt;/label&gt;
  
            &lt;label class="item item-input" &gt;
  
              &lt;input name="2" type="text" ng-model="product.unite" placeholder="unité de cette produit"&gt;
            &lt;/label&gt;
  
            ...
  
  
            &lt;div class="item button button-block button-positive" ng-click="createProduct(product)" &gt;
            ajouter le produit
            &lt;/div&gt;
  </code></pre>
  
  <p>and this is the controller of products : </p>
  
  <pre><code>app.controller('productController', function($http, $scope) {
  
  
  
      $scope.createProduct = function (new_prod){
  
      console.log(new_prod);
  
      var req = {
                  method: 'POST',
                  url: "http://localhost:3000/api/products",
                  headers: {
                      'Content-Type': 'application/x-www-form-urlencoded'
                  },
  
                  data: new_prod
              };  
  
      $http(req)
      .then(function(response) {
        console.log(response);
  
  
      }); 
  
      };  
  </code></pre>