Skip to content

Commit a39890a

Browse files
author
Dave Syer
committed
Replace deprecated success() callback in $http calls
Fixes spring-guidesgh-83
1 parent 36db0f2 commit a39890a

File tree

44 files changed

+179
-147
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+179
-147
lines changed

basic/README.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,8 @@ So let's grab that message in the browser. Modify the "home" controller to load
374374
angular.module('hello', [])
375375
.controller('home', function($http) {
376376
var self = this;
377-
$http.get('/resource/').success(function(data) {
378-
self.greeting = data;
377+
$http.get('/resource/').then(function(response) {
378+
self.greeting = response.data;
379379
})
380380
});
381381
----

basic/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848

4949
<properties>
5050
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
51-
<wro4j.version>1.7.6</wro4j.version>
52-
<java.version>1.7</java.version>
51+
<wro4j.version>1.8.6</wro4j.version>
52+
<java.version>1.8</java.version>
5353
</properties>
5454

5555
<build>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
angular.module('hello', []).controller('home', function($http) {
22
var self = this;
3-
$http.get('resource/').success(function(data) {
4-
self.greeting = data;
3+
$http.get('resource/').then(function(response) {
4+
self.greeting = response.data;
55
})
66
});

double/README.adoc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,14 @@ var authenticate = function(credentials, callback) {
241241
242242
$http.get('user', {
243243
headers : headers
244-
}).success(function(data) {
245-
if (data.name) {
244+
}).then(function(response) {
245+
if (response.data.name) {
246246
self.authenticated = true;
247247
} else {
248248
self.authenticated = false;
249249
}
250250
callback && callback();
251-
}).error(function() {
251+
}, function() {
252252
self.authenticated = false;
253253
callback && callback();
254254
});
@@ -368,7 +368,8 @@ angular.module('admin', []).controller('home',
368368
369369
function($http) {
370370
371-
$http.get('user').success(function(data) {
371+
$http.get('user').then(function(response) {
372+
var data = response.data;
372373
if (data.name) {
373374
self.authenticated = true;
374375
self.user = data;
@@ -422,7 +423,8 @@ We are going to use the roles to make access decisions in the Gateway as well (s
422423
----
423424
$http.get('user', {
424425
headers : headers
425-
}).success(function(data) {
426+
}).then(function(response) {
427+
var data = response.data;
426428
if (data.name) {
427429
self.authenticated = true;
428430
self.user = data.name
@@ -432,7 +434,7 @@ $http.get('user', {
432434
self.admin = false;
433435
}
434436
callback && callback(true);
435-
}).error(function() {
437+
}, function() {
436438
self.authenticated = false;
437439
callback && callback(false);
438440
});

double/admin/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050

5151
<properties>
5252
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
53-
<wro4j.version>1.7.6</wro4j.version>
54-
<java.version>1.7</java.version>
53+
<wro4j.version>1.8.6</wro4j.version>
54+
<java.version>1.8</java.version>
5555
</properties>
5656

5757
<build>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<ol>
2-
<li ng-repeat="item in home.data">{{item.timestamp}} ({{item.user}}): "{{item.content}}"</li>
2+
<li ng-repeat="item in home.data">{{item.timestamp}} ({{item.user}}): "{{item.message}}"</li>
33
</ol>
44
<div ng-show="!home.data || !home.data.length">No changes to show</div>

double/admin/src/main/resources/static/js/admin.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@ function($http) {
88
self.template = user && user.roles && user.roles.indexOf("ROLE_WRITER")>0 ? "write.html" : "read.html";
99
}
1010

11-
$http.get('user').success(function(data) {
11+
$http.get('user').then(function(response) {
12+
var data = response.data;
1213
if (data.name) {
1314
self.authenticated = true;
1415
self.user = data;
1516
computeDefaultTemplate(data);
16-
$http.get('/resource/').success(function(data) {
17-
self.greeting = data;
17+
$http.get('/resource/').then(function(response) {
18+
self.greeting = response.data;
1819
})
1920
} else {
2021
self.authenticated = false;
2122
}
22-
self.error = null
23-
}).error(function(response) {
23+
self.error = null;
24+
}, function(response) {
2425
if (response.status === 0) {
2526
self.error = 'No connection. Verify application is running.';
2627
} else if (response.status == 401) {
@@ -34,8 +35,8 @@ function($http) {
3435
});
3536

3637
self.update = function() {
37-
$http.post('/resource/', {content: self.greeting.content}).success(function(data) {
38-
self.greeting = data;
38+
$http.post('/resource/', {content: self.greeting.content}).then(function(response) {
39+
self.greeting = response.data;
3940
})
4041
}
4142

@@ -45,8 +46,8 @@ function($http) {
4546

4647
self.changes = function() {
4748
self.template = "changes.html";
48-
$http.get('/resource/changes').success(function(data) {
49-
self.data = data;
49+
$http.get('/resource/changes').then(function(response) {
50+
self.data = response.data;
5051
})
5152
}
5253

double/gateway/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@
6969

7070
<properties>
7171
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
72-
<wro4j.version>1.7.6</wro4j.version>
73-
<java.version>1.7</java.version>
72+
<wro4j.version>1.8.6</wro4j.version>
73+
<java.version>1.8</java.version>
7474
</properties>
7575

7676
<build>

double/gateway/src/main/resources/static/js/gateway.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ function($http) {
1919
self.user = ''
2020
$http.get('user', {
2121
headers : headers
22-
}).success(function(data) {
22+
}).then(function(response) {
23+
var data = response.data;
2324
if (data.name) {
2425
self.authenticated = true;
2526
self.user = data.name
@@ -29,7 +30,7 @@ function($http) {
2930
self.admin = false;
3031
}
3132
callback && callback(true);
32-
}).error(function() {
33+
}, function() {
3334
self.authenticated = false;
3435
callback && callback(false);
3536
});

double/resource/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
<properties>
4646
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
47-
<java.version>1.7</java.version>
47+
<java.version>1.8</java.version>
4848
</properties>
4949

5050
<build>

double/ui/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050

5151
<properties>
5252
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
53-
<wro4j.version>1.7.6</wro4j.version>
54-
<java.version>1.7</java.version>
53+
<wro4j.version>1.8.6</wro4j.version>
54+
<java.version>1.8</java.version>
5555
</properties>
5656

5757
<build>

double/ui/src/main/resources/static/js/hello.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,18 @@ function($http) {
66

77
console.log('Loading');
88

9-
$http.get('user').success(function(data) {
9+
$http.get('user').then(function(response) {
10+
var data = response.data;
1011
if (data.name) {
1112
self.authenticated = true;
1213
self.user = data.name
13-
$http.get('/resource/').success(function(data) {
14-
self.greeting = data;
14+
$http.get('/resource/').then(function(response) {
15+
self.greeting = response.data;
1516
})
1617
} else {
1718
self.authenticated = false;
1819
}
19-
}).error(function() {
20+
}, function() {
2021
self.authenticated = false;
2122
});
2223

modular/README.adoc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ For example, here's the `home.js`:
7272
----
7373
angular.module('home', []).controller('home', function($http) {
7474
var self = this;
75-
$http.get('/user/').success(function(data) {
76-
self.user = data.name;
75+
$http.get('/user/').then(function(response) {
76+
self.user = response.data.name;
7777
});
7878
});
7979
----
@@ -286,15 +286,15 @@ angular.module('auth', []).factory(
286286
287287
$http.get('user', {
288288
headers : headers
289-
}).success(function(data) {
290-
if (data.name) {
289+
}).then(function(response) {
290+
if (response.data.name) {
291291
auth.authenticated = true;
292292
} else {
293293
auth.authenticated = false;
294294
}
295295
$location.path(auth.homePath);
296296
callback && callback(auth.authenticated);
297-
}).error(function() {
297+
}, function() {
298298
auth.authenticated = false;
299299
callback && callback(false);
300300
});
@@ -413,10 +413,10 @@ authenticate : function(credentials, callback) {
413413
...
414414
$http.get('user', {
415415
headers : headers
416-
}).success(function(data) {
416+
}).then(function(response) {
417417
...
418418
$location.path(auth.path==auth.loginPath ? auth.homePath : auth.path);
419-
}).error(...);
419+
}, function() { ... });
420420
421421
},
422422
----

modular/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050

5151
<properties>
5252
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
53-
<wro4j.version>1.7.6</wro4j.version>
54-
<java.version>1.7</java.version>
53+
<wro4j.version>1.8.6</wro4j.version>
54+
<java.version>1.8</java.version>
5555
</properties>
5656

5757
<build>

modular/src/main/resources/static/js/auth/auth.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ angular.module('auth', []).factory(
3131

3232
$http.get('user', {
3333
headers : headers
34-
}).success(function(data) {
35-
if (data.name) {
34+
}).then(function(response) {
35+
if (response.data.name) {
3636
auth.authenticated = true;
3737
} else {
3838
auth.authenticated = false;
3939
}
4040
callback && callback(auth.authenticated);
4141
$location.path(auth.path==auth.loginPath ? auth.homePath : auth.path);
42-
}).error(function() {
42+
}, function() {
4343
auth.authenticated = false;
4444
callback && callback(false);
4545
});
@@ -49,9 +49,9 @@ angular.module('auth', []).factory(
4949
clear : function() {
5050
$location.path(auth.loginPath);
5151
auth.authenticated = false;
52-
$http.post(auth.logoutPath, {}).success(function() {
52+
$http.post(auth.logoutPath, {}).then(function() {
5353
console.log("Logout succeeded");
54-
}).error(function(data) {
54+
}, function() {
5555
console.log("Logout failed");
5656
});
5757
},
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
angular.module('home', []).controller('home', function($http) {
22
var self = this;
3-
$http.get('/user/').success(function(data) {
4-
self.user = data.name;
3+
$http.get('/user/').then(function(response) {
4+
self.user = response.data.name;
55
});
66
});
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
angular.module('message', []).controller('message', function($http) {
22
var self = this;
3-
$http.get('/resource/').success(function(data) {
4-
self.greeting = data;
3+
$http.get('/resource/').then(function(response) {
4+
self.greeting = response.data;
55
});
66
});

oauth2-vanilla/README.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,13 +363,13 @@ function($rootScope, $http, $location, $route) {
363363
364364
var self = this;
365365
366-
$http.get('user').success(function(data) {
367-
if (data.name) {
366+
$http.get('user').then(function(response) {
367+
if (response.data.name) {
368368
$rootScope.authenticated = true;
369369
} else {
370370
$rootScope.authenticated = false;
371371
}
372-
}).error(function() {
372+
}, function() {
373373
$rootScope.authenticated = false;
374374
});
375375

oauth2-vanilla/authserver/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
<properties>
4747
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4848
<start-class>demo.AuthserverApplication</start-class>
49-
<wro4j.version>1.7.6</wro4j.version>
50-
<java.version>1.7</java.version>
49+
<wro4j.version>1.8.6</wro4j.version>
50+
<java.version>1.8</java.version>
5151
</properties>
5252

5353
<build>

oauth2-vanilla/resource/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
<properties>
4242
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
43-
<java.version>1.7</java.version>
43+
<java.version>1.8</java.version>
4444
</properties>
4545

4646
<build>

oauth2-vanilla/ui/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@
6565

6666
<properties>
6767
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
68-
<wro4j.version>1.7.6</wro4j.version>
69-
<java.version>1.7</java.version>
68+
<wro4j.version>1.8.6</wro4j.version>
69+
<java.version>1.8</java.version>
7070
</properties>
7171

7272
<build>

oauth2-vanilla/ui/src/main/resources/static/js/hello.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ function($rootScope, $http, $location, $route) {
1616
return $route.current && route === $route.current.controller;
1717
};
1818

19-
$http.get('user').success(function(data) {
20-
if (data.name) {
19+
$http.get('user').then(function(response) {
20+
if (response.data.name) {
2121
$rootScope.authenticated = true;
2222
} else {
2323
$rootScope.authenticated = false;
2424
}
25-
}).error(function() {
25+
}, function() {
2626
$rootScope.authenticated = false;
2727
});
2828

@@ -37,7 +37,7 @@ function($rootScope, $http, $location, $route) {
3737

3838
}).controller('home', function($http) {
3939
var self = this;
40-
$http.get('resource/').success(function(data) {
41-
self.greeting = data;
40+
$http.get('resource/').then(function(response) {
41+
self.greeting = response.data;
4242
})
4343
});

0 commit comments

Comments
 (0)