title: How to make multiple http requests in my case?
body: <p>I am trying to user factory object to make multiple http requests. I have something like</p>
  
  <pre><code>angular.module('App').factory('myFactory', function($http, $q) {
      var service = {};
  
      service.setProduct = function(productObj) {
          _productObj = productObj;
      }
  
      service.makeRequest = function() {
          var deferred = $q.defer();
  
          $http.post('/api/product', _productObj).success(function(data){
              var id = data.id
              //I am not sure how to chain multiple calls by using promise.
              //$http.post('/api/details/, id).success(function(data) {
              //    console.log(data)
              //}
              deferred.resolve(data);
          }).error(function() {
              deferred.reject('error here');
          })
          return deferred.promise;
      }
      return service;
  });
  
  
  
  
  
  
  
  angular.module('App').controller('productCtrl', ['$scope','$http','myFactory',
      function($scope, $http, myFactory) {
          myFactory.setProduct(productObj);
          myFactory.makeRequest()
              .then(function(data) {
                 console.log(data) 
              }, function(data) {
                 alert(data)
              })
  
      }
  ]);
  </code></pre>
  
  <p>I was able to use myfactory.makeRequest() to make one call but not sure how to chain multiple http requests. Can someone please help me? Thanks!</p>