title: How to get a value from returned result "Promise {$$state: Object}"
body: <p>I have this function where GetDataFactory.getDataById(reqData) is function with $http request and returns correct data and when this data arrives I want to use it in another function, but this way keeps returning me  "Promise {$$state: Object}"</p>
  
  <pre><code>    $scope.getData = function(id) {
                      var reqData = {
                          "id": id,
                          "access_token": $scope.access_token
                      };
                      var foo  =  GetDataFactory.getDataById(reqData).then(function(response) {
                          var foo = response.data[0];
                          return foo;
                      });
  
                      console.log(foo); // prints "Promise {$$state: Object}" 
          return foo;
  }
  
  $scope.anotherFunction = function(){
      var id;
      var bar = $scope.getData(id);
  }
  </code></pre>
  
  <p>I'm asking how to return correct value of the data after this $http request is success then return it to another function and do whatever I want to do with this data? Assigning to $scope.foo type variable and timeout is not an option  </p>