title: Angular does not always receive response
body: <p>I am making a get request to a server. The problem is that angular does not always receive a response. I do not understand why. Here is my code.</p>
  
  <pre><code>&lt;button ng-click="getDuration();" ng-init="limit=15;"&gt;
  
   $http.get("/getDuration:"+$scope.duration+":"+$scope.date+":"+$scope.time)
      .then(function (response) {
        $scope.arr = response.data;
  
      }, function(response){
  
      });
  //server
  app.get('/getDuration:duration', function(req, res){
  
  //some date processing
  conn.query('SELECT * FROM thumbnail where thumbnail_date BETWEEN ? AND ?',[date, new_date], function(err, rows, fields) {
      if (err) throw err;
      for (var i in rows) {
          arr.push(rows[i].thumbnail_id);
      }
  
      var myJsonString = JSON.stringify(arr);
      console.log("Sending data");
      res.setHeader('Content-Type', 'application/json');
      res.end(myJsonString);
  
  });
  </code></pre>
  
  <p>});</p>
  
  <p>The browser only refreshes. But sometimes I get the response. What am I doing wrong?The thing is I always get the request on my server side.Thank you.</p>