Skip to content

Commit 04efdd5

Browse files
mkalishpetebacondarwin
authored andcommitted
docs(ngMock): update $http example to use standard promise syntax
Examples were using deprecated .success and .error rather .then Closes angular#13557
1 parent 9f5d76e commit 04efdd5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/ngMock/angular-mocks.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1023,18 +1023,18 @@ angular.mock.dump = function(object) {
10231023
function MyController($scope, $http) {
10241024
var authToken;
10251025
1026-
$http.get('/auth.py').success(function(data, status, headers) {
1027-
authToken = headers('A-Token');
1028-
$scope.user = data;
1026+
$http.get('/auth.py').then(function(response) {
1027+
authToken = response.headers('A-Token');
1028+
$scope.user = response.data;
10291029
});
10301030
10311031
$scope.saveMessage = function(message) {
10321032
var headers = { 'Authorization': authToken };
10331033
$scope.status = 'Saving...';
10341034
1035-
$http.post('/add-msg.py', message, { headers: headers } ).success(function(response) {
1035+
$http.post('/add-msg.py', message, { headers: headers } ).then(function(response) {
10361036
$scope.status = '';
1037-
}).error(function() {
1037+
}).catch(function() {
10381038
$scope.status = 'Failed...';
10391039
});
10401040
};

0 commit comments

Comments
 (0)