Skip to content

Commit f4ff657

Browse files
committed
chore: replace .success() and .error() with .then() and .catch() (#7)
1 parent b4f62f9 commit f4ff657

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ Author: Jonathan Hornung ([JohnnyTheTank](https://github.com/JohnnyTheTank))
2727
youtubeFactory.getVideoById({
2828
videoId: "<VIDEO_ID>",
2929
key: "<YOUR_API_KEY>",
30-
}).success(function (_data) {
30+
}).then(function (_data) {
3131
//on success
32-
}).error(function (_data) {
32+
}).catch(function (_data) {
3333
//on error
3434
});
3535
```
@@ -44,9 +44,9 @@ youtubeFactory.getVideosFromChannelById({
4444
maxResults: "<MAX_RESULTS>", // (optional) valid values: 0-50 | default: 5
4545
pageToken: "<PAGE_TOKEN>", // (optional)
4646
key: "<YOUR_API_KEY>",
47-
}).success(function (_data) {
47+
}).then(function (_data) {
4848
//on success
49-
}).error(function (_data) {
49+
}).catch(function (_data) {
5050
//on error
5151
});
5252
```
@@ -61,9 +61,9 @@ youtubeFactory.getVideosFromSearchByParams({
6161
maxResults: "<MAX_RESULTS>", // (optional) valid values: 0-50 | default: 5
6262
pageToken: "<PAGE_TOKEN>", // (optional)
6363
key: "<YOUR_API_KEY>",
64-
}).success(function (_data) {
64+
}).then(function (_data) {
6565
//on success
66-
}).error(function (_data) {
66+
}).catch(function (_data) {
6767
//on error
6868
});
6969
```
@@ -75,9 +75,9 @@ youtubeFactory.getVideosFromPlaylistById({
7575
maxResults: "<MAX_RESULTS>", // (optional) valid values: 0-50 // default: 5
7676
pageToken: "<PAGE_TOKEN>", // (optional)
7777
key: "<YOUR_API_KEY>",
78-
}).success(function (_data) {
78+
}).then(function (_data) {
7979
//on success
80-
}).error(function (_data) {
80+
}).catch(function (_data) {
8181
//on error
8282
});
8383
```
@@ -90,9 +90,9 @@ youtubeFactory.getChannelById({
9090
channelId: "<CHANNEL_ID>",
9191
pageToken: "<PAGE_TOKEN>", // (optional)
9292
key: "<YOUR_API_KEY>",
93-
}).success(function (_data) {
93+
}).then(function (_data) {
9494
//on success
95-
}).error(function (_data) {
95+
}).catch(function (_data) {
9696
//on error
9797
});
9898
```

demo/js/app.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ app.controller('controller', ['$scope', 'youtubeFactory', function($scope, youtu
77
channelId: "UCVkXCOYluJvD6OPjX9HXj-A",
88
maxResults: "50",
99
key: _apiKey,
10-
}).success(function (_data) {
10+
}).then(function (_data) {
1111
console.info("videos from channel by id", _data);
1212
});
1313

1414
youtubeFactory.getVideosFromSearchByParams({
1515
q: "fcbayern",
1616
maxResults: "50",
1717
key: _apiKey,
18-
}).success(function (_data) {
18+
}).then(function (_data) {
1919
console.info("videos from search by q", _data);
2020
});
2121

@@ -24,29 +24,29 @@ app.controller('controller', ['$scope', 'youtubeFactory', function($scope, youtu
2424
locationRadius: "1000m",
2525
maxResults: "50",
2626
key: _apiKey,
27-
}).success(function (_data) {
27+
}).then(function (_data) {
2828
console.info("videos from search by location", _data);
2929
});
3030

3131
youtubeFactory.getVideosFromPlaylistById({
3232
playlistId: "PLNLa2lbKPczGCueOYxjrwYDuNTBtQveK0",
3333
maxResults: "50",
3434
key: _apiKey,
35-
}).success(function (_data) {
35+
}).then(function (_data) {
3636
console.info("videos from playlist by id", _data);
3737
});
3838

3939
youtubeFactory.getVideoById({
4040
videoId: "rG-haoIhH9o",
4141
key: _apiKey,
42-
}).success(function (_data) {
42+
}).then(function (_data) {
4343
console.info("video by id", _data);
4444
});
4545

4646
youtubeFactory.getChannelById({
4747
channelId: "UCVkXCOYluJvD6OPjX9HXj-A",
4848
key: _apiKey,
49-
}).success(function (_data) {
49+
}).then(function (_data) {
5050
console.info("channel by id", _data);
5151
});
5252

0 commit comments

Comments
 (0)