Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: sindresorhus/got
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7d1aa01e69229ad50ce355589681ff1d1a765627
Choose a base ref
...
head repository: sindresorhus/got
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3a145c0477b2b2f7607107a6f0cb69f6b19574bb
Choose a head ref

Commits on Apr 3, 2018

  1. Copy the full SHA
    81f2537 View commit details

Commits on Apr 20, 2018

  1. Copy the full SHA
    b465f21 View commit details

Commits on May 1, 2018

  1. Copy the full SHA
    82763c8 View commit details
  2. Copy the full SHA
    de9514d View commit details
  3. 8.3.1

    sindresorhus committed May 1, 2018
    Copy the full SHA
    bd3315b View commit details
  4. Require Node.js 8

    sindresorhus committed May 1, 2018
    Copy the full SHA
    2b14537 View commit details
  5. Copy the full SHA
    00fdeea View commit details
  6. Copy the full SHA
    6e7a455 View commit details
  7. Copy the full SHA
    deabbec View commit details
  8. Copy the full SHA
    a03d21e View commit details

Commits on Jun 13, 2018

  1. Copy the full SHA
    54cead2 View commit details

Commits on Jul 3, 2018

  1. fix Buffer.byteLength(req._header) throwing error (#490)

    Anton Egorov authored and lukechilds committed Jul 3, 2018
    Copy the full SHA
    d7641e5 View commit details

Commits on Jul 5, 2018

  1. Copy the full SHA
    058452b View commit details
  2. Catch more errors (#498)

    szmarczak authored and sindresorhus committed Jul 5, 2018
    Copy the full SHA
    f621184 View commit details
  3. Copy the full SHA
    e473a26 View commit details
  4. Copy the full SHA
    74bbee3 View commit details
  5. Bump dependencies

    sindresorhus committed Jul 5, 2018
    Copy the full SHA
    b4f6698 View commit details
  6. Copy the full SHA
    2ee8124 View commit details
  7. Copy the full SHA
    013e668 View commit details
  8. Drop support for body being an Array when form: true

    `new URLSearchParams()` doesn't support this and it's a weird use-case. If you need support for this, just don't set `form: true` and handle stringifying yourself.
    sindresorhus committed Jul 5, 2018
    Copy the full SHA
    dfe5b1c View commit details
  9. Copy the full SHA
    8103bc5 View commit details
  10. Copy the full SHA
    38931e2 View commit details
  11. Code style tweaks

    sindresorhus committed Jul 5, 2018
    Copy the full SHA
    09eee39 View commit details
  12. Copy the full SHA
    b2dab3b View commit details
  13. Copy the full SHA
    346bafc View commit details
  14. Hide the electron import from Webpack

    Becuse Webpack is super annoying: webpack/webpack#196
    sindresorhus committed Jul 5, 2018
    Copy the full SHA
    a4ce0a7 View commit details
  15. Fix merging defaults and options (#499)

    Fixes commit 058452b
    szmarczak authored and sindresorhus committed Jul 5, 2018
    Copy the full SHA
    844c993 View commit details
  16. Document setting multiple cookies

    Fixes #408
    sindresorhus committed Jul 5, 2018
    Copy the full SHA
    0428961 View commit details
  17. Fix the proxy example in the readme

    Fixes #435
    sindresorhus committed Jul 5, 2018
    Copy the full SHA
    77bc901 View commit details

Commits on Jul 6, 2018

  1. Copy the full SHA
    b54b680 View commit details
  2. Meta tweaks

    sindresorhus committed Jul 6, 2018
    Copy the full SHA
    ab5e8e1 View commit details
  3. Copy the full SHA
    d485d7e View commit details

Commits on Jul 7, 2018

  1. Copy the full SHA
    464515f View commit details
  2. Fix timeouts (#501)

    Fixes #478
    Fixes #344
    szmarczak authored and sindresorhus committed Jul 7, 2018
    Copy the full SHA
    be0f17f View commit details
  3. Copy the full SHA
    57ff833 View commit details
  4. Enable AppVeyor

    sindresorhus committed Jul 7, 2018
    Copy the full SHA
    e599a8d View commit details
  5. Copy the full SHA
    ae01825 View commit details

Commits on Jul 8, 2018

  1. Update readme.md

    szmarczak authored Jul 8, 2018
    Copy the full SHA
    76f5847 View commit details
  2. Fix the timeout tests (#506)

    szmarczak authored and sindresorhus committed Jul 8, 2018
    Copy the full SHA
    75dc4c2 View commit details
  3. Simplify wrapping got (#503)

    This renames `got.create()` to `got.extend()` and adds a more powerful `got.create()` method.
    szmarczak authored and sindresorhus committed Jul 8, 2018
    Copy the full SHA
    bc41a49 View commit details

Commits on Jul 9, 2018

  1. Copy the full SHA
    e86aad7 View commit details
  2. Update readme.md

    szmarczak authored Jul 9, 2018
    Copy the full SHA
    112963e View commit details

Commits on Jul 10, 2018

  1. Copy the full SHA
    3eac42a View commit details

Commits on Jul 11, 2018

  1. Copy the full SHA
    28888fa View commit details
  2. Add tests for url-to-options.js (#513)

    alextes authored and sindresorhus committed Jul 11, 2018
    Copy the full SHA
    613fa9b View commit details
  3. Various minor code tweaks (#517)

    jstewmon authored and sindresorhus committed Jul 11, 2018
    Copy the full SHA
    7345a6e View commit details

Commits on Jul 12, 2018

  1. Change reqDelay to 160

    szmarczak authored Jul 12, 2018
    Copy the full SHA
    8fa2bf7 View commit details
  2. Copy the full SHA
    99e3835 View commit details
  3. Support retrying on some HTTP status codes and generally improve the …

    …retry functionality (#508)
    
    Fixes #417 
    Fixes #379
    szmarczak authored and sindresorhus committed Jul 12, 2018
    Copy the full SHA
    98b5664 View commit details

Commits on Jul 13, 2018

  1. Standardize on camelcase (#520)

    jstewmon authored and sindresorhus committed Jul 13, 2018
    Copy the full SHA
    fb5185a View commit details
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
* text=auto
* text=auto eol=lf
*.ai binary
*.js text eol=lf
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
sudo: false
language: node_js
node_js:
- '10'
- '8'
- '6'
- '4'
after_success: npm run coveralls
113 changes: 113 additions & 0 deletions advanced-creation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Advanced creation

> Make calling REST APIs easier by creating niche-specific `got` instances.
#### got.create(settings)

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

Configure a new `got` instance with the provided settings.<br>
**Note:** In contrast to `got.extend()`, this method has no defaults.

##### [options](readme.md#options)

To inherit from parent, set it as `got.defaults.options` or use [`got.mergeOptions(defaults.options, options)`](readme.md#gotmergeoptionsparentoptions-newoptions).<br>
**Note**: Avoid using [object spread](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax#Spread_in_object_literals) as it doesn't work recursively.

##### methods

Type: `Object`

Array of supported request methods.

To inherit from parent, set it as `got.defaults.methods`.

##### handler

Type: `Function`<br>
Default: `undefined`

Function making additional changes to the request.

To inherit from parent, set it as `got.defaults.handler`.<br>
To use the default handler, just omit specifying this.

###### [options](readme.md#options)

**Note:** These options are [normalized](source/normalize-arguments.js).

###### next()

Returns a `Promise` or a `Stream` depending on [`options.stream`](readme.md#stream).

```js
const settings = {
handler: (options, next) => {
if (options.stream) {
// It's a Stream
// We can perform stream-specific actions on it
return next(options)
.on('request', request => setTimeout(() => request.abort(), 50));
}

// It's a Promise
return next(options);
},
methods: got.defaults.methods,
options: got.mergeOptions(got.defaults.options, {
json: true
})
};

const jsonGot = got.create(settings);
```

```js
const defaults = {
handler: (options, next) => next(options),
methods: [
'get',
'post',
'put',
'patch',
'head',
'delete'
],
options: {
retries: 2,
cache: false,
decompress: true,
useElectronNet: false,
throwHttpErrors: true,
headers: {
'user-agent': `${pkg.name}/${pkg.version} (https://github.com/sindresorhus/got)`
}
}
};

// Same as:
const defaults = {
handler: got.defaults.handler,
methods: got.defaults.methods,
options: got.defaults.options
};

const unchangedGot = got.create(defaults);
```

```js
const settings = {
handler: got.defaults.handler,
methods: got.defaults.methods,
options: got.mergeOptions(got.defaults.options, {
headers: {
unicorn: 'rainbow'
}
})
};

const unicorn = got.create(settings);

// Same as:
const unicorn = got.extend({headers: {unicorn: 'rainbow'}});
```
19 changes: 19 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
environment:
matrix:
- nodejs_version: '10'
- nodejs_version: '8'
install:
- ps: Install-Product node $env:nodejs_version
- npm install --global npm@latest
- set PATH=%APPDATA%\npm;%PATH%
- npm install
matrix:
fast_finish: true
build: off
shallow_clone: true
test_script:
- node --version
- npm --version
- npm test
cache:
- '%APPDATA%\npm-cache'
Loading