I'm reading some tutorial on angular.js and came across this expression:
.then(handleRequest, handleRequest)
I was wondering what does it mean to pass 2 of the same functions into .then()?
Here's more context:
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)
}
...
}
angular.module('app', [])
.controller('Main', MainCtrl)
....
})();
And the original tutorial can be found here: https://thinkster.io/angularjs-jwt-auth