title: AngularJS $http function always returning undefined when returning
body: <pre><code>var bar = dataService.makeHttpRequest("GET", "/documents/checkfilename/", null,
              function (data, status, headers, config) {
                  // I can see `true` if I alert(data); here
                  // I want to return the contents of data because
                  // it's a true/false and would perform tasks based
                  // on it being true or false.
  
                  return data;
              });
  
  alert(bar); // this should alert `true` or `false` but is `undefined`
  </code></pre>
  
  <p>Why does alert(bar) always return <code>undefined</code>? I know that <code>data</code> in the above function has <code>true</code> or <code>false</code>, I am able to alert it; but, I want to return it and do things only when it is true.</p>
  
  <p>The <code>dataService.makeHttpRequest</code> service function looks like the following:</p>
  
  <pre><code>dataService.makeHttpRequest = function(requestType, urlString, dataObject, successFunc, errorFunc) {
      $http({
          method:requestType, 
          url:$rootScope.serverAddress+urlString,
          data:dataObject
          })
          .success(successFunc)
          .error(errorFunc);
  };
  </code></pre>