Sending data through my api doesn't work
<p>I'm making a simple todo app. I'm using angular for the frontend and nodejs for the backend. After doing some debugging I now can post data to my mongodb database using Postman though when I do it on my website a new object is being created on the database but without the values that I've given to the object.</p>

<p>This is my model and how I connect to the database:</p>

<pre><code>var mongoose.connect('mongodb://localhost:27017/tododb');
var Todo = mongoose.model('Todo', {
name: String });
</code></pre>

<p>and here is how I handle the request: </p>

<pre><code>app.post('/api/todos', function(req, res){
  Todo.create({name: req.body.name, checked: false},
  function(err, todo){
    if(err) res.send(err);
    Todo.find(function(err, todos){
      if(err) res.send(err);
      res.json(todos);
    });
  });
});
</code></pre>

<p>I'm also using bodyparser to handle the data:</p>

<pre><code>app.use(bodyParser.urlencoded({ extended: true }));
</code></pre>

<p>This is my function on the frontend (AngularJS):</p>

<pre><code>$scope.formData = {};    
$scope.addTodo = function() {
    $http.post('/api/todos', $scope.formData)
        .success(function(data) {
            $scope.todos = data;
            $scope.formData = {}; // clear the form so our user is ready to enter another
            console.log(data);
        })
        .error(function(data) {
            console.log('Error: ' + data);
        });
    };
</code></pre>

<p>Another problem is that the <code>$scope.formData = {}</code> doesn't clear the input field. </p>

<p>And lastly this is the part of my html file that displays the todos:</p>

<pre><code>  &lt;h1&gt;Things you have to do&lt;/h1&gt;
  &lt;li ng-repeat="todo in todos"&gt;
    &lt;p id="todobox"&gt; {{ todo.name }} &lt;/p&gt;
  &lt;/li&gt;
  &lt;form&gt;
    &lt;input type="text" placeholder="I need to do..." ng-model="newTodo"&gt;
    &lt;button ng-click="addTodo()"&gt;Add&lt;/button&gt;
  &lt;/form&gt;
</code></pre>

<p>This is the result I get when I visit <code>localhost:300/api/todos</code></p>

<pre><code>[{"_id":"57275afef11dc77b17a90eda","__v":0},

{"_id":"57275b5ef11dc77b17a90edb","name":"test from postman","__v":0}]
</code></pre>

<p>The first one was created from my input box by clicking the add button, the second one was created by sending a post request with Postman and telling it what the name value is.</p>