title: Nodejs and expressjs. Ajax get request not returning data
body: <p>I have the following Api in JS:</p>
  
  <pre><code>router.route('/books')
      .get(function(req,res){
           Repository.getAll().done( function(result){ res.json(result);},function(err){res.send(err);}); 
      })
      .post(function(req,res){
           Repository.save(req.body).done( function(object){ res.json(object); },function(err){res.send("error seems to have occured");});
      });
  </code></pre>
  
  <p>which works fine when I post using Fiddler and get using chrome browser. But when I attempt to get and post using jquery: </p>
  
  <pre><code>$.ajax({
                                  type: "POST", 
                                  url: "http://localhost:8000/api/books",
                                  data: { "title":"My name is","releaseYear":"1989","director":"me","genre":"horror" }
                              }).done(function(data) {
                              //alert("Success.");
                              console.log("success");
                          }).error(function(data, err, e, o) {
  
                              console.log("error");
                              //alert("Sorry. Server unavailable. ");
                          });
  
                              $.ajax({
                                  type: "GET", 
                                  url: "http://localhost:8000/api/books",
                                  contentType: "application/json"
                              }).done(function(data) {
                              //alert("Success.");
                              console.log("success");
                          }).error(function(data, err, e, o) {
  
                              console.log("error");
                              //alert("Sorry. Server unavailable. ");
                          });
  </code></pre>
  
  <p>Fail/ error callback is fired. I've tried specifying the contentType or removing it but to no avail.</p>
  
  <p>When calling POST, the status code is 200 but no data is returned and calls fail function</p>