title: Is it possible to return a value from the success method of $http.get in AngularJS?
body: <p>I'm having a bit of a brainmelt with promises at the moment.</p>
  
  <p>Given the following code:</p>
  
  <pre><code>$scope.getData = function(user) {
  
      return $http.post('/endpoint', "some post data", { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
          .success(function (response) {
  
              var myThing = { stuff: response.infoData };
  
              localStorageService.set('myData', { stuff: response.infoData });
  
              return myThing;
      });
  };
  </code></pre>
  
  <p>Is the <strong>myThing</strong> object that is returned from the success callback:</p>
  
  <ul>
  <li>returned as the result of the $scope.getData method, or</li>
  <li>ignored and lost to nowhere?</li>
  </ul>
  
  <p>From what I understand:</p>
  
  <ul>
  <li>because $http.post is a promise, it resolves asynchronously and then runs the success method </li>
  <li>when the success method is run, it returns the myThing object but this doesn't magically replace the entire $http.post promise itself</li>
  </ul>
  
  <p>Is this correct? Is there something I'm missing, is there some benefit to returning objects in the success method, or is the return superfluous? (I'm well aware that this is code can be improved but I'm trying to find out specifically why someone would have written this, or if it was entirely a mistake)</p>