title: Cannot POST /api/
body: <p>I am trying to get an <code>Object</code> file to be sent to server using AngularJS and mongoose module for NodeJS. I do get the <code>Object</code> but it doesn't get sent to the server because of <code>Cannot POST /api/appointment/new</code> error.</p>
  
  <p>Here is my <code>HTML</code> file:</p>
  
  <pre><code>&lt;div class="row"&gt;
          &lt;div class="col-sm6 col-sm-offset-3"&gt;
              &lt;div class="row"&gt;
              &lt;strong&gt;Date:&lt;/strong&gt;
                  &lt;label&gt;
                      &lt;input type="text" type="date" ng-model="new.date" class="form-control"&gt;
                  &lt;/label&gt;
                  &lt;strong&gt;Name Surname:&lt;/strong&gt;
                  &lt;label&gt;
                      &lt;input type="text" ng-model="new.nameSurname" class="form-control"&gt;
                  &lt;/label&gt;
              &lt;/div&gt;
              &lt;div class="row"&gt;
                  &lt;strong&gt;Case:&lt;/strong&gt;
                  &lt;label&gt;
                      &lt;input type="text" ng-model="new.description" class="form-control"&gt;
                  &lt;/label&gt;
              &lt;strong&gt;Contact number:&lt;/strong&gt;
                  &lt;label&gt;
                      &lt;input type="tel" ng-model="new.contactNumber" class="form-control"&gt;
                  &lt;/label&gt;
              &lt;button ng-click='createAppointment()'&gt;Create appointment!&lt;/button&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>My server.js file:</p>
  
  <pre><code>var express = require('express');
  var mongoose = require('mongoose');
  var bodyParser = require('body-parser');
  
  var app = express();
  var newAppointment = require('./server/controllers/newAppointment.js');
  
  mongoose.connect('mongodb://localhost:27017/dental');
  
  app.use(bodyParser.json());
  //noinspection JSUnresolvedVariable
  app.use('/app', express.static(__dirname + '/app'));
  //noinspection JSUnresolvedVariable
  app.use('/node_modules', express.static(__dirname + '/node_modules'));
  
  
  app.get('/', function(req, res){
      res.sendfile('index.html');
  });
  
  //New appointment function
  app.post('api/appointment/new', newAppointment.create);
  
  app.listen('3000', function() {
      console.log("Listening on :3000")
  });
  </code></pre>
  
  <p>Server controller:</p>
  
  <pre><code>var mongoose;
  mongoose = require('mongoose');
  var appointment;
  appointment = require('../datasets/appointment.js');
  
  module.exports.create = function(req, response) {
      console.log(req.body)
  };
  </code></pre>
  
  <p>App controller:</p>
  
  <pre><code>(function() {
      //noinspection JSUnresolvedFunction
      angular.module('dentalAdviser')
          .controller('appointmentController', ['$scope', '$state', '$http', function ($scope, $state, $http) {
  
              $scope.createAppointment = (function() {
                  console.log($scope.new);
                  $http.post('api/appointment/new', $scope.new).success(function (response) {
                  }).error(function (error) {
                      console.log(error);
                  })
              });
          }])
  }());
  </code></pre>
  
  <p>And dataset for <code>Object</code>:</p>
  
  <pre><code>var mongoose = require('mongoose');
      module.export = mongoose.model('appointment', {
          nameSurname: String,
          date: String,
          description: String,
          contactNumber: String
      });
  </code></pre>