Skip to content

Commit

Permalink
docs(README): amend .defaults() usage example
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Oct 20, 2018
1 parent 54c3318 commit 5230ffc
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,25 @@ request(myEndpoint(`GET /orgs/:org/repos`))

You can call `.defaults()` again on the returned method, the defaults will cascade.

```js
const myProjectEndpoint = endpoint.defaults({
baseUrl: 'http://github-enterprise.acme-inc.com/api/v3',
headers: {
'user-agent': 'myApp/1.2.3'
},
org: 'my-project'
})
const myProjectEndpointWithAuth = myProjectEndpoint.defaults({
headers: {
authorization: `token 0000000000000000000000000000000000000001`
}
})
```

`myProjectEndpointWithAuth` now defaults the `baseUrl`, `headers['user-agent']`,
`org` and `headers['authorization']` on top of `headers['accept']` that is set
by the global default.

## Special cases

### The `data` parameter – set request body directly
Expand Down

0 comments on commit 5230ffc

Please sign in to comment.