title: MEAN stack/angularjs post request failure
body: <p>Im struggeling to get the server to accept my post request, cause i would like to post some data on /api/kill .</p>
  
  <p><strong><em>For some reason it wont work. how can i make it work?</em></strong></p>
  
  <p>I downloaded the latest release for Mean stack by this link: <a href="https://github.com/dickeyxxx/mean-sample" rel="nofollow">https://github.com/dickeyxxx/mean-sample</a></p>
  
  <p>i tried to edit the article module to start with.</p>
  
  <pre><code>var promise = $http.put('/api/kill', null);
  </code></pre>
  
  <p>response:</p>
  
  <pre><code>angular.js:11756 PUT SITE:3000/server-error 404 (Not Found)
  </code></pre>
  
  <p>attempt number two:</p>
  
  <pre><code>var promise = $http.post('/api/kill', null);
  </code></pre>
  
  <p>returns: </p>
  
  <pre><code>angular.js:11756 POST SITE:3000/api/kill 404 (Not Found)
  </code></pre>
  
  <p>( only if the route is:</p>
  
  <pre><code>  app.route('/api/kill').all(articlesPolicy.isAllowed)
      .get(articles.list)
      .put(articles.killuserbyid)
  </code></pre>
  
  <p>so, if route is :</p>
  
  <pre><code>app.route('/api/kill').all(articlesPolicy.isAllowed)
  .get(articles.list)
  .post(articles.killuserbyid)
  </code></pre>
  
  <p>it would return the orginal:</p>
  
  <pre><code>angular.js:11756 PUT SITE:3000/server-error 404 (Not Found)
  </code></pre>
  
  <p><strong><em>MY codes:</em></strong></p>
  
  <p>in my article.server.routes.js i do have:</p>
  
  <pre><code>    'use strict';
  
  /**
   * Module dependencies
   */
  var articlesPolicy = require('../policies/articles.server.policy'),
    articles = require('../controllers/articles.server.controller');
  
  module.exports = function (app) {
    // Articles collection routes
  
      app.route('/api/kill').all(articlesPolicy.isAllowed)
      .get(articles.list)
      .put(articles.killuserbyid)
      .delete(articles.delete);
  
    // Single article routes
  
  
  
  
  
    // Finish by binding the article middleware
    app.param('articleId', articles.articleByID);
  };
  </code></pre>
  
  <p>my <code>invokeRolesPolicies</code> in articles.server.policy:</p>
  
  <pre><code>    exports.invokeRolesPolicies = function () {
    acl.allow([{
      roles: ['admin'],
      allows: [{
        resources: '/api/kill',
        permissions: '*'
      }]
    }, {
      roles: ['user'],
      allows: [{
        resources: '/api/kill',
        permissions: '*'
      }]
    }, {
      roles: ['guest'],
      allows: [{
        resources: '/api/kill',
        permissions: '*'
      }]
    }]);
  };
  </code></pre>
  
  <p>my <code>ArticlesListController</code> function in list-articles.client.controller:</p>
  
  <pre><code>  ArticlesListController.$inject = ['ArticlesService','$scope'];
  
    function ArticlesListController(ArticlesService,$scope) {
      var vm = this;
  
      vm.testing = function() {
  
  
  
              ArticlesService.test();
  
  
  
      }
  
  
  
  
    }
  </code></pre>
  
  <p>and, finally my articleservice function (articles.client.service)</p>
  
  <pre><code>ArticlesService.$inject = ['$resource','$http'];
  
    function ArticlesService($resource,$http) {
  
          var o = [];
  
          o.test = function() {
              console.log("tester..");
  
              var promise = $http.put('/api/kill', null);
  
  
              promise.then(function(payload) {
                  console.log(payload.data);
  
                });
          }
  
  
          return o;
  
    }
  </code></pre>