title: AngularJS - ReferenceError: success is not defined
body: <p>I am getting "ReferenceError: success is not defined" when doing a Restful call from controller to my node.js back end as follows:</p>
  
  <p>authControllers.js:</p>
  
  <pre><code>authControllers.controller('authCtrl', ['$scope', '$location', '$window', 'UserService', 'AuthenticationService',
  function authCtrl($scope, $location, $window, UserService, AuthenticationService) {
    $scope.me = function() {    
      UserService.me(function(res) {
        $scope.myDetails = res;
      }, function() {
        console.log('Failed to fetch details');
        $rootScope.error = 'Failed to fetch details';
      })
    };      
  }]);
  </code></pre>
  
  <p>authServices.js:</p>
  
  <pre><code>authServices.factory('UserService',['$http', function($http) {
    return {        
      me:function() {
      return $http.get(options.api.base_url + '/me').success(success).error(error)
      }
    }
  }]);
  </code></pre>
  
  <p>html:</p>
  
  <pre><code>&lt;div class="row" data-ng-controller="authCtrl" data-ng-init="me()"&gt;
      &lt;div class="col-lg-12"&gt;
          &lt;div class="panel panel-primary"&gt;
              &lt;div class="panel-heading"&gt;
                  &lt;strong&gt;Your Details&lt;/strong&gt;
              &lt;/div&gt;
              &lt;div class="panel-body"&gt;
                  &lt;p&gt;{{myDetails.data.username}}&lt;/p&gt;
                  &lt;p&gt;{{myDetails.data.email}}&lt;/p&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>A successful nodeJs call is being received and it's returning data as well, but 
  couldn't get it in the front end. Please help !</p>