title: Angular Service to Express API Route + Posting Data
body: <p>I am in the process of converting one of my sites (<a href="http://maskedarmory.com" rel="nofollow">http://maskedarmory.com</a>) from LAMP (using Laravel 4 MVC) over to the MEAN stack and it has been quite a journey thus far.</p>
  
  <p>I have managed to get the landing page up and running and the input POSTing to Angular controller that I have it routed to.</p>
  
  <p>Now, the problem I am having is getting the service to send over the POSTed data that is in Angular over to the Express API.  I keep keeping a 404 Not Found error on the /api/character URL path.</p>
  
  <p>Also, how do I access the 'characterData' variable that is on the Angular side that is being passed over by the factory?  Because I am trying to do a console.log on the 'characterData' variable on the server side and I am sure that that is out of scope.</p>
  
  <p><strong>app/routes.js (Express Routing)</strong></p>
  
  <pre><code>// public/js/services/ArmoryService.js
  angular.module('ArmoryService', []).
      factory('Armory', function($http) {
  
      return {
          // Get the specified character by its profile ID.
          get : function(id) {
              return $http.get('/api/character/' + id);
          },
  
          // call to POST and create a new character armory.
          create : function(characterData) {
              return $http.post('/api/character', characterData);
          }
      }
  });
  </code></pre>
  
  <p><strong>app/routes.js (Express Routing)</strong></p>
  
  <pre><code>module.exports = function(app) {
  
      app.post('/api/character', function(req, res) {
            console.log(characterData);
      });
  
      app.get('/', function(req, res) {
          res.sendfile('./public/index.html'); // load our public/index.html file
      });
  
  };
  </code></pre>
  
  <p>If I do a console.log before the $http.post to the API, 'characterData' has all of the information it should.</p>
  
  <p>I am sure that this is a routing issue of some type, but I will be damned if I can figure it out.</p>
  
  <p>Thanks in advance for your help!</p>