title: AngularJS error: Cannot read property 'get' of undefined
body: <p>I am new to AngularJS and am attempting to retrieve a variable via a $http.get request. I have setup the code similar to a few examples I have seen and am unable to figure out why I am getting the "Cannot read property 'get' of undefined" error message. I have found similar questions on this site but they all pointed to various formatting issues. I could not find one so I am hoping someone may be able to point out what I am doing wrong. Below is my service that is using $http. </p>
  
  <pre><code>(function () {
  
  angular
      .module('golfleague.player')
      .factory('PlayerService', ['$http', function($http){
  
          var onError = function(data) {
              data.errors = data;
  
          };
  
          function getLastName($http) {
              return $http.get('/player/lastname').then(onFetchLastNameComplete, onError);
              function onFetchLastNameComplete(response) {
                  return response;
              }
  
          }
  
          return {
              getLastName: getLastName
          };
  
      }]);
  
  })();
  </code></pre>