File tree 2 files changed +64
-58
lines changed
2 files changed +64
-58
lines changed Original file line number Diff line number Diff line change 1
1
{
2
- "name" : " gh-got" ,
3
- "version" : " 7.0.0" ,
4
- "description" : " Convenience wrapper for Got to interact with the GitHub API" ,
5
- "license" : " MIT" ,
6
- "repository" : " sindresorhus/gh-got" ,
7
- "author" : {
8
- "name" : " Sindre Sorhus" ,
9
- "email" : " sindresorhus@gmail.com" ,
10
- "url" : " sindresorhus.com"
11
- },
12
- "engines" : {
13
- "node" : " >=4"
14
- },
15
- "scripts" : {
16
- "test" : " xo && ava"
17
- },
18
- "files" : [
19
- " index.js"
20
- ],
21
- "keywords" : [
22
- " got" ,
23
- " gh" ,
24
- " github" ,
25
- " api" ,
26
- " request" ,
27
- " http" ,
28
- " https" ,
29
- " get" ,
30
- " url" ,
31
- " uri" ,
32
- " util" ,
33
- " utility"
34
- ],
35
- "dependencies" : {
36
- "got" : " ^8.0.0" ,
37
- "is-plain-obj" : " ^1.1.0"
38
- },
39
- "devDependencies" : {
40
- "ava" : " *" ,
41
- "get-stream" : " ^3.0.0" ,
42
- "nock" : " ^9.1.0" ,
43
- "xo" : " *"
44
- }
2
+ "name" : " gh-got" ,
3
+ "version" : " 7.0.0" ,
4
+ "description" : " Convenience wrapper for `got` to interact with the GitHub API" ,
5
+ "license" : " MIT" ,
6
+ "repository" : " sindresorhus/gh-got" ,
7
+ "author" : {
8
+ "name" : " Sindre Sorhus" ,
9
+ "email" : " sindresorhus@gmail.com" ,
10
+ "url" : " sindresorhus.com"
11
+ },
12
+ "engines" : {
13
+ "node" : " >=4"
14
+ },
15
+ "scripts" : {
16
+ "test" : " xo && ava"
17
+ },
18
+ "files" : [
19
+ " index.js"
20
+ ],
21
+ "keywords" : [
22
+ " got" ,
23
+ " gh" ,
24
+ " github" ,
25
+ " api" ,
26
+ " request" ,
27
+ " http" ,
28
+ " https" ,
29
+ " get" ,
30
+ " url" ,
31
+ " uri" ,
32
+ " util" ,
33
+ " utility"
34
+ ],
35
+ "dependencies" : {
36
+ "got" : " ^8.0.0" ,
37
+ "is-plain-obj" : " ^1.1.0"
38
+ },
39
+ "devDependencies" : {
40
+ "ava" : " *" ,
41
+ "get-stream" : " ^3.0.0" ,
42
+ "nock" : " ^9.1.0" ,
43
+ "xo" : " *"
44
+ }
45
45
}
Original file line number Diff line number Diff line change @@ -18,38 +18,44 @@ Instead of:
18
18
const got = require (' got' );
19
19
const token = ' foo' ;
20
20
21
- got (' https://api.github.com/users/sindresorhus' , {
22
- json: true ,
23
- headers: {
24
- ' accept' : ' application/vnd.github.v3+json' ,
25
- ' authorization' : ` token ${ token} `
26
- }
27
- }).then (res => {
28
- console .log (res .body .login );
21
+ (async () => {
22
+ const {body } = await got (' https://api.github.com/users/sindresorhus' , {
23
+ json: true ,
24
+ headers: {
25
+ ' accept' : ' application/vnd.github.v3+json' ,
26
+ ' authorization' : ` token ${ token} `
27
+ }
28
+ });
29
+
30
+ console .log (body .login );
29
31
// => 'sindresorhus'
30
- });
32
+ })() ;
31
33
```
32
34
33
35
You can do:
34
36
35
37
``` js
36
38
const ghGot = require (' gh-got' );
37
39
38
- ghGot (' users/sindresorhus' , {token: ' foo' }).then (res => {
39
- console .log (res .body .login );
40
+ (async () => {
41
+ const {body } = await ghGot (' users/sindresorhus' , {token: ' foo' });
42
+
43
+ console .log (body .login );
40
44
// => 'sindresorhus'
41
- });
45
+ })() ;
42
46
```
43
47
44
48
Or:
45
49
46
50
``` js
47
51
const ghGot = require (' gh-got' );
48
52
49
- ghGot (' https://api.github.com/users/sindresorhus' , {token: ' foo' }).then (res => {
50
- console .log (res .body .login );
53
+ (async () => {
54
+ const {body } = await ghGot (' https://api.github.com/users/sindresorhus' , {token: ' foo' });
55
+
56
+ console .log (body .login );
51
57
// => 'sindresorhus'
52
- });
58
+ })() ;
53
59
```
54
60
55
61
You can’t perform that action at this time.
0 commit comments