title: AngularJS Best Practice - Factory with multiple methods
body: <p>I have a factory that serves up three different <code>$http.get</code> methods. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>angular.module('myApp')
   .factory('getFactory', function ($http, $q) {
  
   return {
  
    methodOne: function () {
     var deferred  = $q.defer();
  
     $http.get('path/to/data')
      .then(function successCallback (data) {
           deferred.resolve(data);
          },function errorCallback (response) {
                                          console.log(response);
                                  });
  
     return deferred.promise;
    },
  
    methodTwo: function (arg1, arg2) {
     var deferred  = $q.defer();
  
     $http.get('path/to/' + arg1 + '/some/' + arg2 + 'more/data')
      .then(function successCallback (data) {
           deferred.resolve(data);
          },function errorCallback (response) {
                                          console.log(response);
                                  });
  
     return deferred.promise;
    },
  
    methodThree: function (arg1, arg2, arg3) {
     var deferred  = $q.defer();
  
     $http.get('path/to/' + arg1 + '/some/' + arg2 + '/more/' + arg3 + '/data')
      .then(function successCallback (data) {
           deferred.resolve(data);
          },function errorCallback (response) {
                                          console.log(response);
                                  });
  
     return deferred.promise;
    },
   };
   });</code></pre>
  </div>
  </div>
  </p>
  
  <p>Basically, these methods only differ in the path it gets the data from. The data these methods get are handled in the controller. I have been reading a lot of <strong>Angular best practices</strong> on the side and have been seeing DRY (Don't Repeat Yourself) tips. </p>
  
  <p>I feel the code I have above is too repetitive. Is there a better way of coding this <strong>the Angular way</strong>? </p>
  
  <p>**Note: I used the yeoman generator to scaffold the directories of my project. </p>