title: Save response from $http service to an array in angularjs
body: <p>Following is the code, which is consoling the response but unable to set the response to store in <code>$scope.dateWiseData</code> array. Let me know what I am doing wrong.</p>
  
  <pre><code>$scope.dateWiseData = [];
  var tmpArr = [];
  var x = 0;
  for (var i=0; i&lt; 7;i++) {
      $http.post('/api/getdata', {_id: currentUser._id, data: data}).then(function(response){
          console.log(response.data);
          tmpArr.push(response);
          if ( x &lt; 7 ) {
              $scope.dateWiseData = tmpArr;
          }
          x++;
      });
  }
  console.log("--Week Data Array--");
  console.log($scope.dateWiseData);
  </code></pre>