@@ -28,10 +28,10 @@ npm install github-api
2828
2929## Compatibility
3030Github.js is tested on Node:
31+ * 6.x
3132* 5.x
3233* 4.x
3334* 0.12
34- * 0.10
3535
3636## GitHub Tools
3737
@@ -47,11 +47,11 @@ as well. In the meantime, we recommend you to take a look at other projects of t
4747 or using a new promise-based API. For now the promise-based API just returns the
4848 raw HTTP request promise; this might change in the next version.
4949 */
50- var GitHub = require ( ' github-api' ) ;
50+ import GitHub from ' github-api' ;
5151
5252// unauthenticated client
53- var gh = new GitHub ();
54- var gist = gh .getGist (); // not a gist yet
53+ const gh = new GitHub ();
54+ let gist = gh .getGist (); // not a gist yet
5555gist .create ({
5656 public: true ,
5757 description: ' My first gist' ,
@@ -60,37 +60,37 @@ gist.create({
6060 contents: " Aren't gists great!"
6161 }
6262 }
63- }).then (function (httpResponse ) {
63+ }).then (function ({data} ) {
6464 // Promises!
65- var gist = httpResponse . data ;
65+ let gistJson = data;
6666 gist .read (function (err , gist , xhr ) {
6767 // if no error occurred then err == null
6868
69- // gist == httpResponse.data
69+ // gistJson = == httpResponse.data
7070
71- // xhr == httpResponse
71+ // xhr === httpResponse
7272 });
7373});
7474```
7575
7676``` javascript
77- var GitHub = require ( ' github-api' ) ;
77+ import GitHub from ' github-api' ;
7878
7979// basic auth
80- var gh = new GitHub ({
80+ const gh = new GitHub ({
8181 username: ' FOO' ,
8282 password: ' NotFoo'
8383});
8484
85- var me = gh .getUser ();
86- me .getNotification (function (err , notifcations ) {
85+ const me = gh .getUser ();
86+ me .listNotifications (function (err , notifcations ) {
8787 // do some stuff
8888});
8989
90- var clayreimann = gh .getUser (' clayreimann' );
90+ const clayreimann = gh .getUser (' clayreimann' );
9191clayreimann .getStarredRepos ()
92- .then (function (httpPromise ) {
93- var repos = httpPromise . data ;
92+ .then (function ({data : reposJson} ) {
93+ // do stuff with reposJson
9494 });
9595```
9696
0 commit comments