I'm trying to update code from angularjs 1.4.8 to 1.6.6, this means that i'm getting an error as .success and .error have now be deprecated...I've tried googling and following existing examples on stackoverflow but it just doesn't seem to work for my code. Can some kind soul help with suggestions on what I should change the following function to:
$scope.login = function() {
// creating base64 encoded String from user name and password
var base64Credential = btoa($scope.username + ':' + $scope.password);
// calling GET request for getting the user details
$http.get('user', {
headers : {
// setting the Authorisation Header
'Authorization' : 'Basic ' + base64Credential
}
}).success(function(res) {
$scope.password = null;
if (res.authenticated) {
$scope.message = '';
// setting the same header value for all request calling from
// this application
$http.defaults.headers.common['Authorization'] = 'Basic ' + base64Credential;
AuthService.user = res;
$rootScope.$broadcast('LoginSuccessful');
$state.go('workbench');
} else {
$scope.message = 'Login Failed!';
}
}).error(function(error) {
$scope.message = 'Login Failed!';
});
};