title: Returning complete response object in promise of $http
body: <p>I have this method in one of my service to make API calls:</p>
  
  <pre><code>this.postData = function(requestURL, requestObj) {
      var deferred = $q.defer();
      console.log("Reached APIService @POST", requestURL);
      $http.post(requestURL, requestObj).success(
          function(data, status, headers, config, statusText) {
              deferred.resolve(data, status, headers, config, statusText);
              console.log(status);
          }).error(
          function(data, status, headers, config, statusText) {
              deferred.reject(data, status, headers, config, statusText);
              console.log(status);
          });
      return deferred.promise;
  };
  </code></pre>
  
  <p>Basically this worked fine, but recently I needed headers data in my code to fetch the error messages in case of exceptions. I am confused how to get that info in returned promise. The above function when called returns only data and rest 4 items are undefined. I believe promise cannot resolve multiple items as above.</p>
  
  <p>Then how do I returned the object in promise as to get the entire information of object returned by API. (As document says the response contains 5 fields, data, status, headers, config, statusText).</p>
  
  <p>Need help..</p>