title: AngularJS - Need Help Understanding handlerequest and redirect after login
body: <p>I've been following a tutorial on thinkster to complete authorisation using JWTs.
  I have it all working however there is one thing i do not understand fully:</p>
  
  <p>The code:</p>
  
  <pre><code>function MainCtrl(user, auth) {
    var self = this;
  
    function handleRequest(res) {
      var token = res.data ? res.data.token : null;
      if(token) { console.log('JWT:', token); }
      self.message = res.data.message;
    }
  
    self.login = function() {
      user.login(self.username, self.password)
        .then(handleRequest, handleRequest)
    }
  
  }
  </code></pre>
  
  <p>Can anyone help me understanding what is actually happening in this line</p>
  
  <pre><code>.then(handleRequest, handleRequest)
  </code></pre>
  
  <p>namely what does this handleRequest, why is written twice like that?</p>
  
  <p>Also, if after successful login, if i wanted to go to the homepage can i just add something like:</p>
  
  <pre><code>.success(){
      $location.path('/newValue')
  }
  </code></pre>
  
  <p>Thanks</p>