Skip to content

Commit 03d15c3

Browse files
committed
chore: replace .success() and .error() with .then() and .catch() (#1)
1 parent 5cb88fe commit 03d15c3

File tree

4 files changed

+24
-21
lines changed

4 files changed

+24
-21
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ Author: Jonathan Hornung ([JohnnyTheTank](https://github.com/JohnnyTheTank))
2525
githubFactory.getUser({
2626
user:"<USERNAME_NAME>",
2727
access_token:"<ACCESS_TOKEN>"
28-
}).success(function(_data){
28+
}).then(function(_data){
2929
//on success
30-
}).error(function (_data) {
30+
}).catch(function (_data) {
3131
//on error
3232
});
3333
```
@@ -38,9 +38,9 @@ githubFactory.getRepoByUserAndName({
3838
user:"<USER_NAME>",
3939
repo:"<REPO_NAME>",
4040
access_token:"<ACCESS_TOKEN>"
41-
}).success(function(_data){
41+
}).then(function(_data){
4242
//on success
43-
}).error(function (_data) {
43+
}).catch(function (_data) {
4444
//on error
4545
});
4646
```
@@ -54,9 +54,9 @@ githubFactory.getReposByName({
5454
order:"<SORT_ORDER>", // (optional) 'desc', 'asc'
5555
per_page:"<ITEMS_PER_PAGE>", // (optional) valid values: 1-100 | default: 30
5656
access_token:"<ACCESS_TOKEN>"
57-
}).success(function(_data){
57+
}).then(function(_data){
5858
//on success
59-
}).error(function (_data) {
59+
}).catch(function (_data) {
6060
//on error
6161
});
6262
```
@@ -69,9 +69,9 @@ githubFactory.getReposByUser({
6969
order:"<SORT_ORDER>", // (optional) 'desc', 'asc'
7070
per_page:"<ITEMS_PER_PAGE>", // (optional) valid values: 1-100 | default: 30
7171
access_token:"<ACCESS_TOKEN>"
72-
}).success(function(_data){
72+
}).then(function(_data){
7373
//on success
74-
}).error(function (_data) {
74+
}).catch(function (_data) {
7575
//on error
7676
});
7777
```
@@ -86,9 +86,9 @@ githubFactory.getEventsFromRepoByUserAndName({
8686
order:"<SORT_ORDER>", // (optional) 'desc', 'asc'
8787
per_page:"<ITEMS_PER_PAGE>", // (optional) valid values: 1-100 | default: 30
8888
access_token:"<ACCESS_TOKEN>"
89-
}).success(function(_data){
89+
}).then(function(_data){
9090
//on success
91-
}).error(function (_data) {
91+
}).catch(function (_data) {
9292
//on error
9393
});
9494
```
@@ -101,9 +101,9 @@ githubFactory.getEventsByUser({
101101
order:"<SORT_ORDER>", // (optional) 'desc', 'asc'
102102
per_page:"<ITEMS_PER_PAGE>", // (optional) valid values: 1-100 | default: 30
103103
access_token:"<ACCESS_TOKEN>"
104-
}).success(function(_data){
104+
}).then(function(_data){
105105
//on success
106-
}).error(function (_data) {
106+
}).catch(function (_data) {
107107
//on error
108108
});
109109
```

bower.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "angular-github-api-factory",
33
"description": "angularjs factory for github json rest api requests",
4-
"version": "0.1.2",
5-
"main": "Gruntfile.js",
4+
"version": "0.5.0",
5+
"main": "dist/angular-github-api-factory.js",
66
"authors": [
77
"Jonathan Hornung"
88
],

demo/js/app.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ app.controller('controller', ['$scope', 'githubFactory', function($scope, github
66
githubFactory.getUser({
77
user:"xremix",
88
access_token:_access_token
9-
}).success(function(_data){
9+
}).then(function(_data){
1010
console.info("user", _data);
1111
});
1212

@@ -22,15 +22,15 @@ app.controller('controller', ['$scope', 'githubFactory', function($scope, github
2222
q:"apiNG-plugin",
2323
per_page: 20,
2424
access_token:_access_token
25-
}).success(function(_data){
25+
}).then(function(_data){
2626
console.info("repos by name", _data);
2727
});
2828

2929
githubFactory.getEventsByUser({
3030
user:"xremix",
3131
per_page: 20,
3232
access_token:_access_token
33-
}).success(function(_data){
33+
}).then(function(_data){
3434
console.info("events by user", _data);
3535
});
3636

@@ -39,7 +39,7 @@ app.controller('controller', ['$scope', 'githubFactory', function($scope, github
3939
repo:"apiNG",
4040
per_page: 100,
4141
access_token:_access_token
42-
}).success(function(_data){
42+
}).then(function(_data){
4343
console.info("events from repo by user and name", _data);
4444
});
4545

@@ -48,7 +48,7 @@ app.controller('controller', ['$scope', 'githubFactory', function($scope, github
4848
repo:"xGallerify",
4949
per_page: 20,
5050
access_token:_access_token
51-
}).success(function(_data){
51+
}).then(function(_data){
5252
console.info("repo by user and name", _data);
5353
});
5454

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "angular-github-api-factory",
3-
"version": "0.1.2",
3+
"version": "0.5.2",
44
"description": "angularjs factory for github json rest api requests",
5-
"main": "Gruntfile.js",
5+
"main": "dist/angular-github-api-factory.js",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1"
88
},
@@ -23,6 +23,9 @@
2323
"url": "https://github.com/JohnnyTheTank/angular-github-api-factory/issues"
2424
},
2525
"homepage": "https://github.com/JohnnyTheTank/angular-github-api-factory#readme",
26+
"dependencies": {
27+
"angular": "*"
28+
},
2629
"devDependencies": {
2730
"grunt": "^0.4.5",
2831
"grunt-contrib-uglify": "^0.11.0",

0 commit comments

Comments
 (0)