title: AngularJS $http.get won't work with node.js RESTful
body: <p>I have a problem with my AngularJS application. I build a Node.js RESTful API for simple GET and POST functions. If I use a test client to send the http-request, all worked fine and I get my data back.
  But if I try to use the same request in my angular-js application, I got an error and I don't know why.</p>
  
  <p>here is the code of my node.js app</p>
  
  <p>the www.js:</p>
  
  <pre><code>var app = require('../app');
  var http = require('http');
  
  var port = '3000';
  app.set('port', port);
  var server = http.createServer(app);
  server.listen(port);
  </code></pre>
  
  <p>app.js:</p>
  
  <pre><code>var express = require('express');
  var bodyParser = require('body-parser');
  
  var routes = require('./routes/index');
  var users = require('./routes/users');
  
  var app = express();
  
  app.use(bodyParser.json());
  
  app.use('/api/v1/', routes);
  app.use('/api/v1/users', users);
  </code></pre>
  
  <p>users.js:</p>
  
  <pre><code>router.get('/', function (req, res, next) {
  
      db_pool.getConnection(function (err, conn) {
          if (err) {
              conn.release();
              res.json({"code": 100, "status": "Error in connection database"});
              return;
          }
  
          console.log('connected as id ' + conn.threadId);
          conn.query("select * from Users", function (err, rows) {
              conn.release();
              if (!err) {
                  res.setHeader('content-type', 'application/json');
                  res.json(rows); // fetch rows
              } else {
                  res.json({"code": 404, "status": "No Users available"});
              }
          });
  
          conn.on('error', function (err) {
              res.json({"code": 100, "status": "Error in connection database"});
              return;
          });
      });
  
  });
  </code></pre>
  
  <p>And here is my Angular-JS code:
  app.js:</p>
  
  <pre><code>'use strict';
  
  angular.module('tutorialApp', [])
      .controller('UsersCtrl', function($scope, $http){
          $http.get('http://localhost:3000/api/v1/users').success(function(usersResponse) {
              $scope.users = usersResponse.data;
          }).error(function (response, status, header, config) {
              alert("ouh, an error...");
          });
      });
  </code></pre>
  
  <p>and the HTML-Site:</p>
  
  <pre><code>&lt;script src="../js/angular.min.js"&gt;&lt;/script&gt;
  &lt;script src="../js/modules/app.js"&gt;&lt;/script&gt;
  
  
  &lt;div class="container"&gt;
      &lt;input type="text" ng-model="search"&gt;
  
      &lt;p ng-show="search"&gt;You searching for: {{search}}&lt;/p&gt;
  
      &lt;table class="table" ng-controller="UsersCtrl"&gt;
          &lt;tr ng-repeat="user in users | filter:search"&gt;
              &lt;td&gt;{{user.user_id}}&lt;/td&gt;
              &lt;td&gt;{{user.first_name}}&lt;/td&gt;
              &lt;td&gt;{{user.last_name}}&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>what do I wrong?</p>