diff --git a/index.js b/index.js index 53e93af6..3068db16 100644 --- a/index.js +++ b/index.js @@ -360,7 +360,7 @@ class Ky { this.request, this._options, error, - this._retryCount, + this._retryCount ); // If `stop` is returned from the hook, the retry process is stopped diff --git a/package.json b/package.json index 41b07ca6..42771a28 100644 --- a/package.json +++ b/package.json @@ -56,9 +56,9 @@ "node-fetch": "^2.5.0", "nyc": "^14.1.1", "puppeteer": "^1.15.0", - "rollup": "^1.11.3", - "tsd": "^0.7.2", - "xo": "^0.24.0" + "rollup": "^1.27.0", + "tsd": "^0.11.0", + "xo": "^0.25.3" }, "xo": { "envs": [ diff --git a/readme.md b/readme.md index 316ea72e..481a9eea 100644 --- a/readme.md +++ b/readme.md @@ -130,7 +130,7 @@ Type: `object` ##### method -Type: `string`
+Type: `string`\ Default: `get` HTTP method used to make the request. @@ -145,7 +145,7 @@ Shortcut for sending JSON. Use this instead of the `body` option. Accepts a plai ##### searchParams -Type: `string | object | Array> | URLSearchParams`
+Type: `string | object | Array> | URLSearchParams`\ Default: `''` Search parameters to include in the request URL. Setting this will override all existing search parameters in the input URL. @@ -180,7 +180,7 @@ Notes: ##### retry -Type: `object | number`
+Type: `object | number`\ Default: - `limit`: `2` @@ -212,7 +212,7 @@ import ky from 'ky'; ##### timeout -Type: `number | false`
+Type: `number | false`\ Default: `10000` Timeout in milliseconds for getting a response. Can not be greater than 2147483647. @@ -220,14 +220,14 @@ If set to `false`, there will be no timeout. ##### hooks -Type: `object`
+Type: `object`\ Default: `{beforeRequest: [], beforeRetry: [], afterResponse: []}` Hooks allow modifications during the request lifecycle. Hook functions may be async and are run serially. ###### hooks.beforeRequest -Type: `Function[]`
+Type: `Function[]`\ Default: `[]` This hook enables you to modify the request right before it is sent. Ky will make no further changes to the request after this. The hook function receives `request` and `options` as arguments. You could, for example, modify the `request.headers` here. @@ -255,7 +255,7 @@ const api = ky.extend({ ###### hooks.beforeRetry -Type: `Function[]`
+Type: `Function[]`\ Default: `[]` This hook enables you to modify the request right before retry. Ky will make no further changes to the request after this. The hook function receives the normalized request and options, an error instance and the retry count as arguments. You could, for example, modify `request.headers` here. @@ -279,7 +279,7 @@ import ky from 'ky'; ###### hooks.afterResponse -Type: `Function[]`
+Type: `Function[]`\ Default: `[]` This hook enables you to read and optionally modify the response. The hook function receives normalized request, options, and a clone of the response as arguments. The return value of the hook function will be used by Ky as the response object if it's an instance of [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response). @@ -319,7 +319,7 @@ import ky from 'ky'; ##### throwHttpErrors -Type: `boolean`
+Type: `boolean`\ Default: `true` Throw a `HTTPError` for error responses (non-2xx status codes). diff --git a/test/browser.js b/test/browser.js index 9c8cca12..9cabfdb2 100644 --- a/test/browser.js +++ b/test/browser.js @@ -57,7 +57,7 @@ test('aborting a request', withPage, async (t, page) => { const controller = new AbortController(); const request = window.ky(`${url}/test`, {signal: controller.signal}).text(); controller.abort(); - return request.catch(error => error.toString()); + return request.catch(error_ => error_.toString()); }, server.url); t.is(error, 'AbortError: The user aborted a request.'); @@ -82,7 +82,7 @@ test('throws TimeoutError even though it does not support AbortController', with window.ky = window.ky.default; const request = window.ky(`${url}/endless`, {timeout: 500}).text(); - return request.catch(error => error.toString()); + return request.catch(error_ => error_.toString()); }, server.url); t.is(error, 'TimeoutError: Request timed out'); @@ -148,7 +148,7 @@ test('throws if onDownloadProgress is not a function', withPage, async (t, page) window.ky = window.ky.default; const request = window.ky(url, {onDownloadProgress: 1}).text(); - return request.catch(error => error.toString()); + return request.catch(error_ => error_.toString()); }, server.url); t.is(error, 'TypeError: The `onDownloadProgress` option must be a function'); @@ -170,7 +170,7 @@ test('throws if does not support ReadableStream', withPage, async (t, page) => { window.ky = window.ky.default; const request = window.ky(url, {onDownloadProgress: () => {}}).text(); - return request.catch(error => error.toString()); + return request.catch(error_ => error_.toString()); }, server.url); t.is(error, 'Error: Streams are not supported in your environment. `ReadableStream` is missing.');