title: Why do i have to use return twice and how does it work?
body: <p>I wrote a wrapper for the $http service in angular using a service. Why do i have to return bothe the http call and my result to have it available in a controller?</p>
  
  <p>this is the function in the service:</p>
  
  <pre><code>this.fetchData = function(url, parameters)
      {
          if (parameters)
          {
              return $http.get(url, {params: parameters}).then(
                  function (response) {
                      console.log(response);
                      return response.data.data;
                  },
                  function (response) {
                      console.log(response);
                  });
          }
          else
          {
              return $http.get(url).then(
                  function (response) {
                      console.log(response);
                  },
                  function (response) {
                      console.log(response);
                  }
              );
          }
      }
  </code></pre>
  
  <p>and this is where i call it in the controller:</p>
  
  <pre><code>test.fetchData('/jewelry-room/move-user.action', {user:2000, task:7}).then(
          function (response) {
              console.log(response);
          },
          function (response) {
              console.log(response);
          }
      );
  </code></pre>