Skip to content

Commit

Permalink
Document the .defaults property (#649)
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Oct 30, 2018
1 parent 84a9534 commit 46c0951
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion advanced-creation.md
Expand Up @@ -6,7 +6,8 @@

Example: [gh-got](https://github.com/sindresorhus/gh-got/blob/master/index.js)

Configure a new `got` instance with the provided settings. You can access the settings through `got.defaults`.<br>
Configure a new `got` instance with the provided settings. You can access the resolved options with the `.defaults` property on the instance.

**Note:** In contrast to `got.extend()`, this method has no defaults.

##### [options](readme.md#options)
Expand Down
8 changes: 7 additions & 1 deletion readme.md
Expand Up @@ -584,7 +584,7 @@ Sets `options.method` to the method name and makes a request.

#### got.extend([options])

Configure a new `got` instance with default `options`. `options` are merged with the parent instance's `defaults.options` using [`got.mergeOptions`](#gotmergeoptionsparentoptions-newoptions).
Configure a new `got` instance with default `options`. The `options` are merged with the parent instance's `defaults.options` using [`got.mergeOptions`](#gotmergeoptionsparentoptions-newoptions). You can access the resolved options with the `.defaults` property on the instance.

```js
const client = got.extend({
Expand Down Expand Up @@ -650,6 +650,12 @@ Options are deeply merged to a new object. The value of each key is determined a
- If the new property is an `Array`, it overwrites the old one with a deep clone of the new property.
- Otherwise, the new value is assigned to the key.

#### got.defaults

Type: `Object`

The default Got options.

## Errors

Each error contains (if available) `body`, `statusCode`, `statusMessage`, `host`, `hostname`, `method`, `path`, `protocol` and `url` properties to make debugging easier.
Expand Down

0 comments on commit 46c0951

Please sign in to comment.