title: Getting 404 trying http PUT using Node Express Postgresql
body: <p>Edit: NEVERMIND - I made a small mistake in the Angular service. My bad.</p>
  
  <p>I'm trying to teach myself more backend by building a simple CMS using angular, Node and Express, and PostgreSql. I figured out how to do achieve all the CRUD functionality except UPDATE. I thought I understood what to do but I can't figure out where I'm going wrong. I keep getting a 404. What am I misunderstanding or going about the wrong way? I know this is simple but I'm pretty new so any help in understanding where I'm getting confused is really appreciated. Here's the relevant code: </p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;form ng-submit="updateBlogEntry(specificBlog.id, specificBlog.title, specificBlog.author, specificBlog.imageurl, specificBlog.content)"&gt;
      &lt;h2&gt;Title:&lt;/h2&gt;
          &lt;input type="text" ng-model="specificBlog.title"&gt;&lt;/input&gt;
        &lt;br&gt;
      &lt;h3&gt;Author:&lt;/h3&gt;
          &lt;input type="text" ng-model="specificBlog.author"&gt;&lt;/input&gt;
        &lt;br&gt;
      &lt;h3&gt;Photo:&lt;/h3&gt;
          &lt;input type="text" ng-model="specificBlog.imageurl"&gt;&lt;/input&gt;
        &lt;br&gt;
      &lt;h3&gt;Content:&lt;/h3&gt;
        &lt;textarea type="text" rows="5" cols="50" ng-model="specificBlog.content"&gt;
        &lt;/textarea&gt;
        &lt;br&gt;
      &lt;button type="submit"&gt;Save Changes&lt;/button&gt;
    &lt;/form&gt;
  </code></pre>
  
  <p><strong>Angular Controller</strong></p>
  
  <pre><code>  var id = $stateParams.id;
    var title = $stateParams.title;
    var author = $stateParams.author;
    var imageurl = $stateParams.imageurl;
    var content = $stateParams.content;
  
    $scope.updateBlogEntry = function(id, title, author, imageurl, content) {
      adminService.updateBlogEntry(id, title, author, imageurl, content);
    }
  </code></pre>
  
  <p><strong>Angular Service</strong></p>
  
  <pre><code>this.updateBlogEntry = function(id, title, author, imageurl, content) {
      return $http({
        method: 'PUT',
        url: 'updateBlogEntry/' + id,
        data: {
          id: id,
          title: title,
          author: author,
          imageurl: imageurl,
          content: content
        }
      })
      .success(function(data) {
        alert("Entry Updated");
      })
      .error(function(data) {
        alert("Error Updating"); 
      })
  </code></pre>
  
  <p><strong>Server Index</strong></p>
  
  <pre><code>// EXTERNAL MODULES //
  var express = require('express');
  var bodyParser = require('body-parser');
  var session = require('express-session');
  var massive = require('massive');
  
  // CONFIG //
  var config = require('./config');
  
  // EXPRESS //
  var app = module.exports = express();
  
  app.use(express.static(__dirname + './../dist'));
  app.use(bodyParser.json());
  
  // MASSIVE //
  var massiveUri = config.MASSIVE_URI;
  var massiveServer = massive.connectSync({
      connectionString: massiveUri
  });
  app.set('db', massiveServer);
  var db = app.get('db');
  
  var dbSetup = require('./services/dbSetup');
  dbSetup.run();
  
  // CONTROLLERS //
  var userCtrl = require('./controllers/userCtrl');
  var blogCtrl = require('./controllers/blogCtrl');
  
  
  // Blog Endpoints //
  app.post('/api/createBlogEntry', blogCtrl.createBlogEntry);
  app.get('/api/getBlogEntries', blogCtrl.readBlogEntries);
  app.get('/api/getBlogEntry/:id', blogCtrl.readBlogEntry);
  // BUG Why isn't this working?
  app.put('/api/updateBlogEntry/:id', blogCtrl.updateBlogEntry);
  
  // CONNECTIONS //
  var port = config.PORT;
  app.listen(port, function() {
      console.log('Listening on port ' + port);
  });
  </code></pre>
  
  <p><strong>Node Controller</strong></p>
  
  <pre><code>updateBlogEntry: function(req, res, next){
          db.blogs.blog_update([
              req.params.id,
              req.body.title,
              req.body.author,
              req.body.imageurl,
              req.body.content
          ],
          function(err, results){
              if (err){
                  console.error(err);
                  res.send(err);
              } else {
                  res.send(results[0]);
              }
          })
      }
  </code></pre>
  
  <p><strong>blog_update.sql</strong></p>
  
  <pre><code>UPDATE blogs
  set
    title     = COALESCE($2, title),
    author    = COALESCE($3, author),
    imageurl  = COALESCE($4, imageurl),
    content   = COALESCE($5, content)
  WHERE id = $1
  
  RETURNING * ;
  </code></pre>
  
  <p><strong>The error in the console:</strong></p>
  
  <pre><code>angular.js:11881 PUT http://localhost:3000/updateBlogEntry/1 404 (Not Found)
  </code></pre>