diff --git a/package.json b/package.json index 41e0253..6db166e 100644 --- a/package.json +++ b/package.json @@ -1,45 +1,45 @@ { - "name": "gh-got", - "version": "7.0.0", - "description": "Convenience wrapper for Got to interact with the GitHub API", - "license": "MIT", - "repository": "sindresorhus/gh-got", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "engines": { - "node": ">=4" - }, - "scripts": { - "test": "xo && ava" - }, - "files": [ - "index.js" - ], - "keywords": [ - "got", - "gh", - "github", - "api", - "request", - "http", - "https", - "get", - "url", - "uri", - "util", - "utility" - ], - "dependencies": { - "got": "^8.0.0", - "is-plain-obj": "^1.1.0" - }, - "devDependencies": { - "ava": "*", - "get-stream": "^3.0.0", - "nock": "^9.1.0", - "xo": "*" - } + "name": "gh-got", + "version": "7.0.0", + "description": "Convenience wrapper for `got` to interact with the GitHub API", + "license": "MIT", + "repository": "sindresorhus/gh-got", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "engines": { + "node": ">=4" + }, + "scripts": { + "test": "xo && ava" + }, + "files": [ + "index.js" + ], + "keywords": [ + "got", + "gh", + "github", + "api", + "request", + "http", + "https", + "get", + "url", + "uri", + "util", + "utility" + ], + "dependencies": { + "got": "^8.0.0", + "is-plain-obj": "^1.1.0" + }, + "devDependencies": { + "ava": "*", + "get-stream": "^3.0.0", + "nock": "^9.1.0", + "xo": "*" + } } diff --git a/readme.md b/readme.md index 41d3e7b..05d501e 100644 --- a/readme.md +++ b/readme.md @@ -18,16 +18,18 @@ Instead of: const got = require('got'); const token = 'foo'; -got('https://api.github.com/users/sindresorhus', { - json: true, - headers: { - 'accept': 'application/vnd.github.v3+json', - 'authorization': `token ${token}` - } -}).then(res => { - console.log(res.body.login); +(async () => { + const {body} = await got('https://api.github.com/users/sindresorhus', { + json: true, + headers: { + 'accept': 'application/vnd.github.v3+json', + 'authorization': `token ${token}` + } + }); + + console.log(body.login); //=> 'sindresorhus' -}); +})(); ``` You can do: @@ -35,10 +37,12 @@ You can do: ```js const ghGot = require('gh-got'); -ghGot('users/sindresorhus', {token: 'foo'}).then(res => { - console.log(res.body.login); +(async () => { + const {body} = await ghGot('users/sindresorhus', {token: 'foo'}); + + console.log(body.login); //=> 'sindresorhus' -}); +})(); ``` Or: @@ -46,10 +50,12 @@ Or: ```js const ghGot = require('gh-got'); -ghGot('https://api.github.com/users/sindresorhus', {token: 'foo'}).then(res => { - console.log(res.body.login); +(async () => { + const {body} = await ghGot('https://api.github.com/users/sindresorhus', {token: 'foo'}); + + console.log(body.login); //=> 'sindresorhus' -}); +})(); ```