{"_id":"@kikobeats/got","_rev":"3-d306a75653f4f4b183e73fdf1ddb452e","name":"@kikobeats/got","dist-tags":{"latest":"11.8.9"},"versions":{"11.8.7":{"name":"@kikobeats/got","version":"11.8.7","keywords":["http","https","http2","get","got","url","uri","request","simple","curl","wget","fetch","net","network","gzip","brotli","requests","human-friendly","axios","superagent","node-fetch","ky"],"license":"MIT","_id":"@kikobeats/got@11.8.7","maintainers":[{"name":"kikobeats","email":"josefrancisco.verdu@gmail.com"}],"homepage":"https://github.com/kikobeats/got#readme","bugs":{"url":"https://github.com/kikobeats/got/issues"},"xo":{"rules":{"node/prefer-global/url":"off","import/no-anonymous-default-export":"off","@typescript-eslint/no-empty-function":"off","node/prefer-global/url-search-params":"off","@typescript-eslint/no-implicit-any-catch":"off"},"ignores":["documentation/examples/*"]},"ava":{"files":["test/*"],"timeout":"1m","typescript":{"rewritePaths":{"test/":"dist/test/"}}},"nyc":{"exclude":["**/test/**"],"extension":[".ts"]},"dist":{"shasum":"0632038d084abe852fb0f511c8fa629e8fed8ea4","tarball":"https://registry.npmjs.org/@kikobeats/got/-/got-11.8.7.tgz","fileCount":49,"integrity":"sha512-zagTsJivYAxePoGq/9RmkQH5mweCQCNKhYCEJCxtuNMEEK2huOEH6uOgIb8b4DPJl33xZYDXR8Fl/L7lA9FEWg==","signatures":[{"sig":"MEQCIBzEtarrYo5vxKfbk5uvqjBtFVSfxAVcAdcYDXdDGd9VAiBO1yL4bPXFawjaVjfaB9t0f63SVum5cTAoWWjftI+Qeg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":269370},"main":"dist/source","types":"dist/source","engines":{"node":">=10.19.0"},"funding":"https://github.com/sindresorhus/got?sponsor=1","gitHead":"ccc3ca2120a74a9c8e6ded734ea96d2edc79e9f2","scripts":{"test":"xo && npm run build && nyc --reporter=html --reporter=text ava","build":"del-cli dist && tsc","prepare":"npm run build","release":"np"},"_npmUser":{"name":"kikobeats","email":"josefrancisco.verdu@gmail.com"},"repository":{"url":"git+https://github.com/kikobeats/got.git","type":"git"},"_npmVersion":"11.13.0","description":"Human-friendly and powerful HTTP request library for Node.js","directories":{},"sideEffects":false,"_nodeVersion":"24.16.0","dependencies":{"p-cancelable":"^2.0.0","responselike":"^2.0.0","http2-wrapper":"^1.0.0-beta.5.2","lowercase-keys":"^2.0.0","@sindresorhus/is":"^4.0.0","cacheable-lookup":"^5.0.3","cacheable-request":"^7.0.2","@types/responselike":"^1.0.0","decompress-response":"^6.0.0","@szmarczak/http-timer":"^4.0.5","@types/cacheable-request":"^6.0.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"np":"^6.4.0","xo":"^0.34.1","ava":"^3.11.1","nyc":"^15.1.0","pem":"^1.14.4","nock":"^13.0.4","pify":"^5.0.0","axios":"^0.20.0","delay":"^4.4.0","sinon":"^9.0.3","tempy":"^1.0.0","del-cli":"^3.0.1","express":"^4.17.1","p-event":"^4.2.0","benchmark":"^2.1.4","coveralls":"^3.1.0","form-data":"^3.0.0","@types/pem":"^1.9.5","get-stream":"^6.0.0","node-fetch":"^2.6.0","typescript":"4.0.3","@types/node":"^14.14.0","@types/pify":"^3.0.2","slow-stream":"0.0.4","@types/sinon":"^9.0.5","tough-cookie":"^4.0.0","@types/express":"^4.17.7","@types/request":"^2.48.5","@ava/typescript":"^1.1.1","@types/benchmark":"^1.0.33","@types/node-fetch":"^2.5.7","create-test-server":"^3.0.1","to-readable-stream":"^2.1.0","@types/tough-cookie":"^4.0.0","@sinonjs/fake-timers":"^6.0.1","@sindresorhus/tsconfig":"^0.7.0"},"runkitExampleFilename":"./documentation/examples/runkit-example.js","_npmOperationalInternal":{"tmp":"tmp/got_11.8.7_1789423226037_0.840540761156864","host":"s3://npm-registry-packages-npm-production"}},"11.8.8":{"name":"@kikobeats/got","version":"11.8.8","keywords":["http","https","http2","get","got","url","uri","request","simple","curl","wget","fetch","net","network","gzip","brotli","requests","human-friendly","axios","superagent","node-fetch","ky"],"license":"MIT","_id":"@kikobeats/got@11.8.8","maintainers":[{"name":"kikobeats","email":"josefrancisco.verdu@gmail.com"}],"homepage":"https://github.com/kikobeats/got#readme","bugs":{"url":"https://github.com/kikobeats/got/issues"},"xo":{"rules":{"node/prefer-global/url":"off","import/no-anonymous-default-export":"off","@typescript-eslint/no-empty-function":"off","node/prefer-global/url-search-params":"off","@typescript-eslint/no-implicit-any-catch":"off"},"ignores":["documentation/examples/*"]},"ava":{"files":["test/*"],"timeout":"1m","typescript":{"rewritePaths":{"test/":"dist/test/"}}},"nyc":{"exclude":["**/test/**"],"extension":[".ts"]},"dist":{"shasum":"2a6fc5159399fd419dc17465532cf43a89dc0ed1","tarball":"https://registry.npmjs.org/@kikobeats/got/-/got-11.8.8.tgz","fileCount":51,"integrity":"sha512-7fEwT4opnSZFpbICTwqfjFurMeiAXWJqQto8W8+kGJcEpyhseYuLfsAq4C1DIwi7E58zX2Apvfl79CMZLk6Pyw==","signatures":[{"sig":"MEUCIAnjjaqfl3cn31J43DRkmMOAXk84RDFlAmsv7XgRE4jIAiEAg1eDeD9yS7BkqNgkQTlIlqax331xuvYFpWkBsyIYEAY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEUCIQDxYizON5AArnvHxP7wZ1G9eau4UZzQEf/7zUQhRxE5VgIgaPwNvoRsgVNhcJkanaWWJMaL4pn0xCKbIfK0hqa1tfE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":274512},"main":"dist/source","types":"dist/source","engines":{"node":">=10.19.0"},"funding":"https://github.com/sindresorhus/got?sponsor=1","gitHead":"4767219d7a25323100a712abf44d55608d2d1a4a","scripts":{"test":"xo && npm run build && nyc --reporter=html --reporter=text ava","build":"del-cli dist && tsc","prepare":"npm run build","release":"np"},"_npmUser":{"name":"kikobeats","email":"josefrancisco.verdu@gmail.com"},"repository":{"url":"git+https://github.com/kikobeats/got.git","type":"git"},"_npmVersion":"11.13.0","description":"Human-friendly and powerful HTTP request library for Node.js","directories":{},"sideEffects":false,"_nodeVersion":"24.16.0","dependencies":{"p-cancelable":"^2.0.0","responselike":"^2.0.0","http2-wrapper":"^1.0.0-beta.5.2","lowercase-keys":"^2.0.0","@sindresorhus/is":"^4.0.0","cacheable-lookup":"^5.0.3","cacheable-request":"^7.0.2","@types/responselike":"^1.0.0","decompress-response":"^6.0.0","@szmarczak/http-timer":"^4.0.5","@types/cacheable-request":"^6.0.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"np":"^6.4.0","xo":"^0.34.1","ava":"^3.11.1","nyc":"^15.1.0","pem":"^1.14.4","nock":"^13.0.4","pify":"^5.0.0","axios":"^0.20.0","delay":"^4.4.0","sinon":"^9.0.3","tempy":"^1.0.0","del-cli":"^3.0.1","express":"^4.17.1","p-event":"^4.2.0","benchmark":"^2.1.4","coveralls":"^3.1.0","form-data":"^3.0.0","@types/pem":"^1.9.5","get-stream":"^6.0.0","node-fetch":"^2.6.0","typescript":"4.0.3","@types/node":"^14.14.0","@types/pify":"^3.0.2","slow-stream":"0.0.4","@types/sinon":"^9.0.5","tough-cookie":"^4.0.0","@types/express":"^4.17.7","@types/request":"^2.48.5","@ava/typescript":"^1.1.1","@types/benchmark":"^1.0.33","@types/node-fetch":"^2.5.7","create-test-server":"^3.0.1","to-readable-stream":"^2.1.0","@types/tough-cookie":"^4.0.0","@sinonjs/fake-timers":"^6.0.1","@sindresorhus/tsconfig":"^0.7.0"},"runkitExampleFilename":"./documentation/examples/runkit-example.js","_npmOperationalInternal":{"tmp":"tmp/got_11.8.8_1789540417926_0.4837516896881029","host":"s3://npm-registry-packages-npm-production"}},"11.8.9":{"xo":{"rules":{"node/prefer-global/url":"off","import/no-anonymous-default-export":"off","@typescript-eslint/no-empty-function":"off","node/prefer-global/url-search-params":"off","@typescript-eslint/no-implicit-any-catch":"off"},"ignores":["documentation/examples/*"]},"_id":"@kikobeats/got@11.8.9","ava":{"files":["test/*"],"timeout":"1m","typescript":{"rewritePaths":{"test/":"dist/test/"}}},"nyc":{"exclude":["**/test/**"],"extension":[".ts"]},"dist":{"shasum":"88b75b61f19a1d05dd954c3a5919fbf1f85d9bcb","tarball":"https://registry.npmjs.org/@kikobeats/got/-/got-11.8.9.tgz","fileCount":51,"integrity":"sha512-prp4bep3y3RBFwpkOg4x8BJLCMPtQG8v4XK/ngXsqPDcbY5W0m/8D1w4nd9i/cuizo6Tmd7XyIRRdPIHjx/vyA==","signatures":[{"sig":"MEUCIQDbXE6UDwI+RLYrwgWKfZFIgg8UQs+mf7lO2LVRCPHioAIgLTJmbU8gbV/ZJNnN+GKDWUREV05H56tmL+BAoRajn/A=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCTU7mGI27LFnV7uKWoChzWRGEE1zS0fAOONSRbh1CiNgIhAMlxsdidr+IO4S3HG3OEc4Zd8jhh9+OaKgyyejxPGouo"}],"unpackedSize":276020},"main":"dist/source","name":"@kikobeats/got","types":"dist/source","engines":{"node":">=10.19.0"},"funding":"https://github.com/sindresorhus/got?sponsor=1","license":"MIT","scripts":{"test":"xo && npm run build && nyc --reporter=html --reporter=text ava","build":"del-cli dist && tsc","release":"npm run release:version && npm run release:changelog && npm run release:commit && npm run release:tag","postrelease":"npm run release:tags && npm run release:github && (ci-publish || npm publish --access=public)","release:tag":"git tag -a v$(node -p \"require('./package.json').version\") -m \"v$(node -p \"require('./package.json').version\")\"","release:tags":"git push origin HEAD:v11 --follow-tags","release:commit":"git add package.json CHANGELOG.md && git commit -m \"chore(release): $(node -p \"require('./package.json').version\")\"","release:github":"npx -y github-generate-release","release:version":"standard-version --skip.changelog --skip.commit --skip.tag","release:changelog":"conventional-changelog -p conventionalcommits -i CHANGELOG.md -s"},"version":"11.8.9","_npmUser":{"name":"kikobeats","email":"josefrancisco.verdu@gmail.com"},"keywords":["http","https","http2","get","got","url","uri","request","simple","curl","wget","fetch","net","network","gzip","brotli","requests","human-friendly","axios","superagent","node-fetch","ky"],"commitlint":{"rules":{"body-max-line-length":[0]},"extends":["@commitlint/config-conventional"]},"repository":{"url":"kikobeats/got","type":"git"},"description":"Human-friendly and powerful HTTP request library for Node.js","directories":{},"maintainers":[{"name":"kikobeats","email":"josefrancisco.verdu@gmail.com"}],"sideEffects":false,"_nodeVersion":"24.16.0","dependencies":{"p-cancelable":"^2.0.0","responselike":"^2.0.0","http2-wrapper":"^1.0.0-beta.5.2","lowercase-keys":"^2.0.0","@sindresorhus/is":"^4.0.0","cacheable-lookup":"^5.0.3","cacheable-request":"npm:@kikobeats/cacheable-request@^7.0.7","@types/responselike":"^1.0.0","decompress-response":"^6.0.0","@szmarczak/http-timer":"^4.0.5","@types/cacheable-request":"^6.0.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"xo":"^0.34.1","ava":"^3.11.1","nyc":"^15.1.0","pem":"^1.14.4","nock":"^13.0.4","pify":"^5.0.0","axios":"^0.20.0","delay":"^4.4.0","sinon":"^9.0.3","tempy":"^1.0.0","del-cli":"^3.0.1","express":"^4.17.1","p-event":"^4.2.0","benchmark":"^2.1.4","coveralls":"^3.1.0","form-data":"^3.0.0","@types/pem":"^1.9.5","ci-publish":"latest","get-stream":"^6.0.0","node-fetch":"^2.6.0","typescript":"4.0.3","@types/node":"^14.14.0","@types/pify":"^3.0.2","slow-stream":"0.0.4","@types/sinon":"^9.0.5","tough-cookie":"^4.0.0","@types/express":"^4.17.7","@types/request":"^2.48.5","@ava/typescript":"^1.1.1","@commitlint/cli":"latest","@types/benchmark":"^1.0.33","simple-git-hooks":"latest","standard-version":"latest","@types/node-fetch":"^2.5.7","create-test-server":"^3.0.1","to-readable-stream":"^2.1.0","@types/tough-cookie":"^4.0.0","@sinonjs/fake-timers":"^6.0.1","@sindresorhus/tsconfig":"^0.7.0","conventional-changelog-cli":"latest","@commitlint/config-conventional":"latest"},"simple-git-hooks":{"commit-msg":"npx commitlint --edit"},"runkitExampleFilename":"./documentation/examples/runkit-example.js","_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/got_11.8.9_1789656140082_0.3047807304118195"}}},"time":{"created":"2026-09-14T22:00:25.789Z","modified":"2026-09-17T14:42:20.328Z","11.8.7":"2026-09-14T22:00:26.179Z","11.8.8":"2026-09-16T06:33:38.020Z","11.8.9":"2026-09-17T14:42:20.177Z"},"license":"MIT","keywords":["http","https","http2","get","got","url","uri","request","simple","curl","wget","fetch","net","network","gzip","brotli","requests","human-friendly","axios","superagent","node-fetch","ky"],"repository":{"url":"kikobeats/got","type":"git"},"description":"Human-friendly and powerful HTTP request library for Node.js","maintainers":[{"name":"kikobeats","email":"josefrancisco.verdu@gmail.com"}],"readme":"<div align=\"center\">\n\t<br>\n\t<br>\n\t<img width=\"360\" src=\"media/logo.svg\" alt=\"Got\">\n\t<br>\n\t<br>\n\t<br>\n\t<p align=\"center\">Huge thanks to <a href=\"https://moxy.studio\"><img src=\"https://sindresorhus.com/assets/thanks/moxy-logo.svg\" valign=\"middle\" width=\"150\"></a> for sponsoring Sindre Sorhus!\n\t</p>\n\t<p align=\"center\"><sup>(they love Got too!)</sup></p>\n\t<br>\n\t<br>\n</div>\n\n> Human-friendly and powerful HTTP request library for Node.js\n\n> [!NOTE]\n> `@kikobeats/got` is a maintained fork of [Got v11](https://github.com/sindresorhus/got/tree/v11.8.6), which is [no longer maintained upstream](https://github.com/sindresorhus/got/issues/2469). It keeps the v11 API and fixes compatibility with current Node.js releases:\n>\n> - Retries on connection errors no longer stop early or crash with uncaught exceptions on Node.js 24.20+ ([#1](https://github.com/Kikobeats/got/pull/1), [#6](https://github.com/Kikobeats/got/pull/6)).\n> - Piping into a Got stream with `stream.pipeline()` no longer throws `The payload has been already provided` ([#2](https://github.com/Kikobeats/got/pull/2), [#6](https://github.com/Kikobeats/got/pull/6)).\n> - Requests using the `cache` option no longer hang with keep-alive agents, the default since Node.js 20 ([#2](https://github.com/Kikobeats/got/pull/2)), including with `cacheable-request` forks that bundle `clone-response@2` ([#4](https://github.com/Kikobeats/got/pull/4)).\n>\n> Replace `got@11` everywhere in your dependency tree with an alias in `package.json` (`overrides` for npm, `pnpm.overrides` for pnpm):\n>\n> ```json\n> {\n> \t\"overrides\": {\n> \t\t\"got@11\": \"npm:@kikobeats/got@^11.8.8\"\n> \t},\n> \t\"pnpm\": {\n> \t\t\"overrides\": {\n> \t\t\t\"got@11\": \"npm:@kikobeats/got@^11.8.8\"\n> \t\t}\n> \t}\n> }\n> ```\n\n[![Build Status: Linux](https://travis-ci.com/sindresorhus/got.svg?branch=master)](https://travis-ci.com/github/sindresorhus/got)\n[![Coverage Status](https://coveralls.io/repos/github/sindresorhus/got/badge.svg?branch=master)](https://coveralls.io/github/sindresorhus/got?branch=master)\n[![Downloads](https://img.shields.io/npm/dm/got.svg)](https://npmjs.com/got)\n[![Install size](https://packagephobia.now.sh/badge?p=got)](https://packagephobia.now.sh/result?p=got)\n\n[Moving from Request?](documentation/migration-guides.md) [*(Note that Request is unmaintained)*](https://github.com/request/request/issues/3142)\n\n[See how Got compares to other HTTP libraries](#comparison)\n\nFor browser usage, we recommend [Ky](https://github.com/sindresorhus/ky) by the same people.\n\n## Highlights\n\n- [Promise API](#api)\n- [Stream API](#streams)\n- [Pagination API](#pagination)\n- [HTTP2 support](#http2)\n- [Request cancelation](#aborting-the-request)\n- [RFC compliant caching](#cache-adapters)\n- [Follows redirects](#followredirect)\n- [Retries on failure](#retry)\n- [Progress events](#onuploadprogress-progress)\n- [Handles gzip/deflate/brotli](#decompress)\n- [Timeout handling](#timeout)\n- [Errors with metadata](#errors)\n- [JSON mode](#json-mode)\n- [WHATWG URL support](#url)\n- [HTTPS API](#advanced-https-api)\n- [Hooks](#hooks)\n- [Instances with custom defaults](#instances)\n- [Types](#types)\n- [Composable](documentation/advanced-creation.md#merging-instances)\n- [Plugins](documentation/lets-make-a-plugin.md)\n- [Used by 4K+ packages and 1.8M+ repos](https://github.com/sindresorhus/got/network/dependents)\n- [Actively maintained](https://github.com/sindresorhus/got/graphs/contributors)\n- [Trusted by many companies](#widely-used)\n\n## Install\n\n```\n$ npm install got\n```\n\n## Usage\n\n###### Promise\n\n```js\nconst got = require('got');\n\n(async () => {\n\ttry {\n\t\tconst response = await got('https://sindresorhus.com');\n\t\tconsole.log(response.body);\n\t\t//=> '<!doctype html> ...'\n\t} catch (error) {\n\t\tconsole.log(error.response.body);\n\t\t//=> 'Internal server error ...'\n\t}\n})();\n```\n\n###### JSON\n\n```js\nconst got = require('got');\n\n(async () => {\n\tconst {body} = await got.post('https://httpbin.org/anything', {\n\t\tjson: {\n\t\t\thello: 'world'\n\t\t},\n\t\tresponseType: 'json'\n\t});\n\n\tconsole.log(body.data);\n\t//=> {hello: 'world'}\n})();\n```\n\nSee [JSON mode](#json-mode) for more details.\n\n###### Streams\n\n```js\nconst stream = require('stream');\nconst {promisify} = require('util');\nconst fs = require('fs');\nconst got = require('got');\n\nconst pipeline = promisify(stream.pipeline);\n\n(async () => {\n\tawait pipeline(\n\t\tgot.stream('https://sindresorhus.com'),\n\t\tfs.createWriteStream('index.html')\n\t);\n\n\t// For POST, PUT, PATCH, and DELETE methods, `got.stream` returns a `stream.Writable`.\n\tawait pipeline(\n\t\tfs.createReadStream('index.html'),\n\t\tgot.stream.post('https://sindresorhus.com')\n\t);\n})();\n```\n\n**Tip:** `from.pipe(to)` doesn't forward errors. Instead, use [`stream.pipeline(from, ..., to, callback)`](https://nodejs.org/api/stream.html#stream_stream_pipeline_streams_callback).\n\n**Note:** While `got.post('https://example.com')` resolves, `got.stream.post('https://example.com')` will hang indefinitely until a body is provided. If there's no body on purpose, remember to `.end()` the stream or set the [`body`](#body) option to an empty string.\n\n### API\n\nIt's a `GET` request by default, but can be changed by using different methods or via [`options.method`](#method).\n\n**By default, Got will retry on failure. To disable this option, set [`options.retry`](#retry) to `0`.**\n\n#### got(url?, options?)\n\nReturns a Promise giving a [Response object](#response) or a [Got Stream](#streams-1) if `options.isStream` is set to true.\n\n##### url\n\nType: `string | object`\n\nThe URL to request, as a string, a [`https.request` options object](https://nodejs.org/api/https.html#https_https_request_options_callback), or a [WHATWG `URL`](https://nodejs.org/api/url.html#url_class_url).\n\nProperties from `options` will override properties in the parsed `url`.\n\nIf no protocol is specified, it will throw a `TypeError`.\n\n**Note:** The query string is **not** parsed as search params. Example:\n\n```js\ngot('https://example.com/?query=a b'); //=> https://example.com/?query=a%20b\ngot('https://example.com/', {searchParams: {query: 'a b'}}); //=> https://example.com/?query=a+b\n\n// The query string is overridden by `searchParams`\ngot('https://example.com/?query=a b', {searchParams: {query: 'a b'}}); //=> https://example.com/?query=a+b\n```\n\n##### options\n\nType: `object`\n\nAny of the [`https.request`](https://nodejs.org/api/https.html#https_https_request_options_callback) options.\n\n**Note:** Legacy URL support is disabled. `options.path` is supported only for backwards compatibility. Use `options.pathname` and `options.searchParams` instead. `options.auth` has been replaced with `options.username` & `options.password`.\n\n###### method\n\nType: `string`\\\nDefault: `GET`\n\nThe HTTP method used to make the request.\n\n###### prefixUrl\n\nType: `string | URL`\n\nWhen specified, `prefixUrl` will be prepended to `url`. The prefix can be any valid URL, either relative or absolute.\\\nA trailing slash `/` is optional - one will be added automatically.\n\n**Note:** `prefixUrl` will be ignored if the `url` argument is a URL instance.\n\n**Note:** Leading slashes in `input` are disallowed when using this option to enforce consistency and avoid confusion. For example, when the prefix URL is `https://example.com/foo` and the input is `/bar`, there's ambiguity whether the resulting URL would become `https://example.com/foo/bar` or `https://example.com/bar`. The latter is used by browsers.\n\n**Tip:** Useful when used with [`got.extend()`](#custom-endpoints) to create niche-specific Got instances.\n\n**Tip:** You can change `prefixUrl` using hooks as long as the URL still includes the `prefixUrl`. If the URL doesn't include it anymore, it will throw.\n\n```js\nconst got = require('got');\n\n(async () => {\n\tawait got('unicorn', {prefixUrl: 'https://cats.com'});\n\t//=> 'https://cats.com/unicorn'\n\n\tconst instance = got.extend({\n\t\tprefixUrl: 'https://google.com'\n\t});\n\n\tawait instance('unicorn', {\n\t\thooks: {\n\t\t\tbeforeRequest: [\n\t\t\t\toptions => {\n\t\t\t\t\toptions.prefixUrl = 'https://cats.com';\n\t\t\t\t}\n\t\t\t]\n\t\t}\n\t});\n\t//=> 'https://cats.com/unicorn'\n})();\n```\n\n###### headers\n\nType: `object`\\\nDefault: `{}`\n\nRequest headers.\n\nExisting headers will be overwritten. Headers set to `undefined` will be omitted.\n\n###### isStream\n\nType: `boolean`\\\nDefault: `false`\n\nReturns a `Stream` instead of a `Promise`. This is equivalent to calling `got.stream(url, options?)`.\n\n###### body\n\nType: `string | Buffer | stream.Readable` or [`form-data` instance](https://github.com/form-data/form-data)\n\n**Note #1:** The `body` option cannot be used with the `json` or `form` option.\n\n**Note #2:** If you provide this option, `got.stream()` will be read-only.\n\n**Note #3:** If you provide a payload with the `GET` or `HEAD` method, it will throw a `TypeError` unless the method is `GET` and the `allowGetBody` option is set to `true`.\n\n**Note #4:** This option is not enumerable and will not be merged with the instance defaults.\n\nThe `content-length` header will be automatically set if `body` is a `string` / `Buffer` / `fs.createReadStream` instance / [`form-data` instance](https://github.com/form-data/form-data), and `content-length` and `transfer-encoding` are not manually set in `options.headers`.\n\n###### json\n\nType: `object | Array | number | string | boolean | null` *(JSON-serializable values)*\n\n**Note #1:** If you provide this option, `got.stream()` will be read-only.\\\n**Note #2:** This option is not enumerable and will not be merged with the instance defaults.\n\nJSON body. If the `Content-Type` header is not set, it will be set to `application/json`.\n\n###### context\n\nType: `object`\n\nUser data. In contrast to other options, `context` is not enumerable.\n\n**Note:** The object is never merged, it's just passed through. Got will not modify the object in any way.\n\nIt's very useful for storing auth tokens:\n\n```js\nconst got = require('got');\n\nconst instance = got.extend({\n\thooks: {\n\t\tbeforeRequest: [\n\t\t\toptions => {\n\t\t\t\tif (!options.context || !options.context.token) {\n\t\t\t\t\tthrow new Error('Token required');\n\t\t\t\t}\n\n\t\t\t\toptions.headers.token = options.context.token;\n\t\t\t}\n\t\t]\n\t}\n});\n\n(async () => {\n\tconst context = {\n\t\ttoken: 'secret'\n\t};\n\n\tconst response = await instance('https://httpbin.org/headers', {context});\n\n\t// Let's see the headers\n\tconsole.log(response.body);\n})();\n```\n\n###### responseType\n\nType: `string`\\\nDefault: `'text'`\n\n**Note:** When using streams, this option is ignored.\n\nThe parsing method. Can be `'text'`, `'json'` or `'buffer'`.\n\nThe promise also has `.text()`, `.json()` and `.buffer()` methods which return another Got promise for the parsed body.\\\nIt's like setting the options to `{responseType: 'json', resolveBodyOnly: true}` but without affecting the main Got promise.\n\nExample:\n\n```js\n(async () => {\n\tconst responsePromise = got(url);\n\tconst bufferPromise = responsePromise.buffer();\n\tconst jsonPromise = responsePromise.json();\n\n\tconst [response, buffer, json] = await Promise.all([responsePromise, bufferPromise, jsonPromise]);\n\t// `response` is an instance of Got Response\n\t// `buffer` is an instance of Buffer\n\t// `json` is an object\n})();\n```\n\n```js\n// This\nconst body = await got(url).json();\n\n// is semantically the same as this\nconst body = await got(url, {responseType: 'json', resolveBodyOnly: true});\n```\n\n**Note:** `buffer` will return the raw body buffer. Modifying it will also alter the result of `promise.text()` and `promise.json()`. Before overwritting the buffer, please copy it first via `Buffer.from(buffer)`. See https://github.com/nodejs/node/issues/27080\n\n###### parseJson\n\nType: `(text: string) => unknown`\\\nDefault: `(text: string) => JSON.parse(text)`\n\nA function used to parse JSON responses.\n\n<details>\n<summary>Example</summary>\n\nUsing [`bourne`](https://github.com/hapijs/bourne) to prevent prototype pollution:\n\n```js\nconst got = require('got');\nconst Bourne = require('@hapi/bourne');\n\n(async () => {\n\tconst parsed = await got('https://example.com', {\n\t\tparseJson: text => Bourne.parse(text)\n\t}).json();\n\n\tconsole.log(parsed);\n})();\n```\n</details>\n\n###### stringifyJson\n\nType: `(object: unknown) => string`\\\nDefault: `(object: unknown) => JSON.stringify(object)`\n\nA function used to stringify the body of JSON requests.\n\n<details>\n<summary>Examples</summary>\n\nIgnore properties starting with `_`:\n\n```js\nconst got = require('got');\n\n(async () => {\n\tawait got.post('https://example.com', {\n\t\tstringifyJson: object => JSON.stringify(object, (key, value) => {\n\t\t\tif (key.startsWith('_')) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treturn value;\n\t\t}),\n\t\tjson: {\n\t\t\tsome: 'payload',\n\t\t\t_ignoreMe: 1234\n\t\t}\n\t});\n})();\n```\n\nAll numbers as strings:\n\n```js\nconst got = require('got');\n\n(async () => {\n\tawait got.post('https://example.com', {\n\t\tstringifyJson: object => JSON.stringify(object, (key, value) => {\n\t\t\tif (typeof value === 'number') {\n\t\t\t\treturn value.toString();\n\t\t\t}\n\n\t\t\treturn value;\n\t\t}),\n\t\tjson: {\n\t\t\tsome: 'payload',\n\t\t\tnumber: 1\n\t\t}\n\t});\n})();\n```\n</details>\n\n###### resolveBodyOnly\n\nType: `boolean`\\\nDefault: `false`\n\nWhen set to `true` the promise will return the [Response body](#body-1) instead of the [Response](#response) object.\n\n###### cookieJar\n\nType: `object` | [`tough.CookieJar` instance](https://github.com/salesforce/tough-cookie#cookiejar)\n\n**Note:** If you provide this option, `options.headers.cookie` will be overridden.\n\nCookie support. You don't have to care about parsing or how to store them. [Example](#cookies).\n\n###### cookieJar.setCookie\n\nType: `Function<Promise>`\n\nThe function takes two arguments: `rawCookie` (`string`) and `url` (`string`).\n\n###### cookieJar.getCookieString\n\nType: `Function<Promise>`\n\nThe function takes one argument: `url` (`string`).\n\n###### ignoreInvalidCookies\n\nType: `boolean`\\\nDefault: `false`\n\nIgnore invalid cookies instead of throwing an error. Only useful when the `cookieJar` option has been set. Not recommended.\n\n###### encoding\n\nType: `string`\\\nDefault: `'utf8'`\n\n[Encoding](https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings) to be used on `setEncoding` of the response data.\n\nTo get a [`Buffer`](https://nodejs.org/api/buffer.html), you need to set [`responseType`](#responseType) to `buffer` instead. Don't set this option to `null`.\n\n**Note:** This doesn't affect streams! Instead, you need to do `got.stream(...).setEncoding(encoding)`.\n\n###### form\n\nType: `object`\n\n**Note #1:** If you provide this option, `got.stream()` will be read-only.\\\n**Note #2:** This option is not enumerable and will not be merged with the instance defaults.\n\nThe form body is converted to a query string using [`(new URLSearchParams(object)).toString()`](https://nodejs.org/api/url.html#url_constructor_new_urlsearchparams_obj).\n\nIf the `Content-Type` header is not present, it will be set to `application/x-www-form-urlencoded`.\n\n###### searchParams\n\nType: `string | object<string, string | number> | URLSearchParams`\n\nQuery string that will be added to the request URL. This will override the query string in `url`.\n\nIf you need to pass in an array, you can do it using a `URLSearchParams` instance:\n\n```js\nconst got = require('got');\n\nconst searchParams = new URLSearchParams([['key', 'a'], ['key', 'b']]);\n\ngot('https://example.com', {searchParams});\n\nconsole.log(searchParams.toString());\n//=> 'key=a&key=b'\n```\n\nThere are some exceptions in regards to `URLSearchParams` behavior:\n\n**Note #1:** `null` values are not stringified, an empty string is used instead.\n\n**Note #2:** `undefined` values are not stringified, the entry is skipped instead.\n\n###### timeout\n\nType: `number | object`\n\nMilliseconds to wait for the server to end the response before aborting the request with [`got.TimeoutError`](#gottimeouterror) error (a.k.a. `request` property). By default, there's no timeout.\n\nThis also accepts an `object` with the following fields to constrain the duration of each phase of the request lifecycle:\n\n- `lookup` starts when a socket is assigned and ends when the hostname has been resolved. Does not apply when using a Unix domain socket.\n- `connect` starts when `lookup` completes (or when the socket is assigned if lookup does not apply to the request) and ends when the socket is connected.\n- `secureConnect` starts when `connect` completes and ends when the handshaking process completes (HTTPS only).\n- `socket` starts when the socket is connected. See [request.setTimeout](https://nodejs.org/api/http.html#http_request_settimeout_timeout_callback).\n- `response` starts when the request has been written to the socket and ends when the response headers are received.\n- `send` starts when the socket is connected and ends with the request has been written to the socket.\n- `request` starts when the request is initiated and ends when the response's end event fires.\n\n###### retry\n\nType: `number | object`\\\nDefault:\n- limit: `2`\n- calculateDelay: `({attemptCount, retryOptions, error, computedValue}) => computedValue | Promise<computedValue>`\n- methods: `GET` `PUT` `HEAD` `DELETE` `OPTIONS` `TRACE`\n- statusCodes: [`408`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) [`413`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/413) [`429`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) [`500`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) [`502`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502) [`503`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503) [`504`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504) [`521`](https://support.cloudflare.com/hc/en-us/articles/115003011431#521error) [`522`](https://support.cloudflare.com/hc/en-us/articles/115003011431#522error) [`524`](https://support.cloudflare.com/hc/en-us/articles/115003011431#524error)\n- maxRetryAfter: `undefined`\n- errorCodes: `ETIMEDOUT` `ECONNRESET` `EADDRINUSE` `ECONNREFUSED` `EPIPE` `ENOTFOUND` `ENETUNREACH` `EAI_AGAIN`\n\nAn object representing `limit`, `calculateDelay`, `methods`, `statusCodes`, `maxRetryAfter` and `errorCodes` fields for maximum retry count, retry handler, allowed methods, allowed status codes, maximum [`Retry-After`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) time and allowed error codes.\n\nIf `maxRetryAfter` is set to `undefined`, it will use `options.timeout`.\\\nIf [`Retry-After`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) header is greater than `maxRetryAfter`, it will cancel the request.\n\nDelays between retries counts with function `1000 * Math.pow(2, retry - 1) + Math.random() * 100`, where `retry` is attempt number (starts from 1).\n\nThe `calculateDelay` property is a `function` that receives an object with `attemptCount`, `retryOptions`, `error` and `computedValue` properties for current retry count, the retry options, error and default computed value. The function must return a delay in milliseconds (or a Promise resolving with it) (`0` return value cancels retry).\n\n**Note:** The `calculateDelay` function is responsible for the entire cache mechanism, including the `limit` property. To support it, you need to check whether `computedValue` is different than `0`.\n\nBy default, it retries *only* on the specified methods, status codes, and on these network errors:\n- `ETIMEDOUT`: One of the [timeout](#timeout) limits were reached.\n- `ECONNRESET`: Connection was forcibly closed by a peer.\n- `EADDRINUSE`: Could not bind to any free port.\n- `ECONNREFUSED`: Connection was refused by the server.\n- `EPIPE`: The remote side of the stream being written has been closed.\n- `ENOTFOUND`: Couldn't resolve the hostname to an IP address.\n- `ENETUNREACH`: No internet connection.\n- `EAI_AGAIN`: DNS lookup timed out.\n\n<a name=\"retry-stream\"></a>\n\nYou can retry Got streams too. The implementation looks like this:\n\n```js\nconst got = require('got');\nconst fs = require('fs');\n\nlet writeStream;\n\nconst fn = (retryCount = 0) => {\n\tconst stream = got.stream('https://example.com');\n\tstream.retryCount = retryCount;\n\n\tif (writeStream) {\n\t\twriteStream.destroy();\n\t}\n\n\twriteStream = fs.createWriteStream('example.com');\n\n\tstream.pipe(writeStream);\n\n\t// If you don't attach the listener, it will NOT make a retry.\n\t// It automatically checks the listener count so it knows whether to retry or not :)\n\tstream.once('retry', fn);\n};\n\nfn();\n```\n\n###### followRedirect\n\nType: `boolean`\\\nDefault: `true`\n\nDefines if redirect responses should be followed automatically.\n\nNote that if a `303` is sent by the server in response to any request type (`POST`, `DELETE`, etc.), Got will automatically request the resource pointed to in the location header via `GET`. This is in accordance with [the spec](https://tools.ietf.org/html/rfc7231#section-6.4.4).\n\n###### methodRewriting\n\nType: `boolean`\\\nDefault: `true`\n\nBy default, redirects will use [method rewriting](https://tools.ietf.org/html/rfc7231#section-6.4). For example, when sending a POST request and receiving a `302`, it will resend the body to the new location using the same HTTP method (`POST` in this case).\n\n###### allowGetBody\n\nType: `boolean`\\\nDefault: `false`\n\n**Note:** The [RFC 7321](https://tools.ietf.org/html/rfc7231#section-4.3.1) doesn't specify any particular behavior for the GET method having a payload, therefore **it's considered an [anti-pattern](https://en.wikipedia.org/wiki/Anti-pattern)**.\n\nSet this to `true` to allow sending body for the `GET` method. However, the [HTTP/2 specification](https://tools.ietf.org/html/rfc7540#section-8.1.3) says that `An HTTP GET request includes request header fields and no payload body`, therefore when using the HTTP/2 protocol this option will have no effect. This option is only meant to interact with non-compliant servers when you have no other choice.\n\n###### maxRedirects\n\nType: `number`\\\nDefault: `10`\n\nIf exceeded, the request will be aborted and a `MaxRedirectsError` will be thrown.\n\n###### decompress\n\nType: `boolean`\\\nDefault: `true`\n\nDecompress the response automatically. This will set the `accept-encoding` header to `gzip, deflate, br` on Node.js 11.7.0+ or `gzip, deflate` for older Node.js versions, unless you set it yourself.\n\nBrotli (`br`) support requires Node.js 11.7.0 or later.\n\nIf this is disabled, a compressed response is returned as a `Buffer`. This may be useful if you want to handle decompression yourself or stream the raw compressed data.\n\n###### cache\n\nType: `object | false`\\\nDefault: `false`\n\n[Cache adapter instance](#cache-adapters) for storing cached response data.\n\n###### cacheOptions\n\nType: `object | undefined`\\\nDefault: `{}`\n\n[Cache options](https://github.com/kornelski/http-cache-semantics#constructor-options) used for the specified request.\n\n###### dnsCache\n\nType: `CacheableLookup | false`\\\nDefault: `false`\n\nAn instance of [`CacheableLookup`](https://github.com/szmarczak/cacheable-lookup) used for making DNS lookups. Useful when making lots of requests to different *public* hostnames.\n\n**Note:** This should stay disabled when making requests to internal hostnames such as `localhost`, `database.local` etc.\\\n`CacheableLookup` uses `dns.resolver4(..)` and `dns.resolver6(...)` under the hood and fall backs to `dns.lookup(...)` when the first two fail, which may lead to additional delay.\n\n###### dnsLookupIpVersion\n\nType: `'auto' | 'ipv4' | 'ipv6'`\\\nDefault: `'auto'`\n\nIndicates which DNS record family to use.\\\nValues:\n - `auto`: IPv4 (if present) or IPv6\n - `ipv4`: Only IPv4\n - `ipv6`: Only IPv6\n\nNote: If you are using the undocumented option `family`, `dnsLookupIpVersion` will override it.\n\n```js\n// `api6.ipify.org` will be resolved as IPv4 and the request will be over IPv4 (the website will respond with your public IPv4)\nawait got('https://api6.ipify.org', {\n\tdnsLookupIpVersion: 'ipv4'\n});\n\n// `api6.ipify.org` will be resolved as IPv6 and the request will be over IPv6 (the website will respond with your public IPv6)\nawait got('https://api6.ipify.org', {\n\tdnsLookupIpVersion: 'ipv6'\n});\n```\n\n###### lookup\n\nType: `Function`\\\nDefault: [`dns.lookup`](https://nodejs.org/api/dns.html#dns_dns_lookup_hostname_options_callback)\n\nCustom DNS resolution logic.\n\nThe function signature is the same as [`dns.lookup`](https://nodejs.org/api/dns.html#dns_dns_lookup_hostname_options_callback).\n\n###### request\n\nType: `Function`\\\nDefault: `http.request | https.request` *(Depending on the protocol)*\n\nCustom request function. The main purpose of this is to [support HTTP2 using a wrapper](https://github.com/szmarczak/http2-wrapper).\n\n###### http2\n\nType: `boolean`\\\nDefault: `false`\n\nIf set to `true`, Got will additionally accept HTTP2 requests.\\\nIt will choose either HTTP/1.1 or HTTP/2 depending on the ALPN protocol.\n\n**Note:** Overriding `options.request` will disable HTTP2 support.\n\n**Note:** This option will default to `true` in the next upcoming major release.\n\n```js\nconst got = require('got');\n\n(async () => {\n\tconst {headers} = await got('https://nghttp2.org/httpbin/anything', {http2: true});\n\tconsole.log(headers.via);\n\t//=> '2 nghttpx'\n})();\n```\n\n###### throwHttpErrors\n\nType: `boolean`\\\nDefault: `true`\n\nDetermines if a [`got.HTTPError`](#gothttperror) is thrown for unsuccessful responses.\n\nIf this is disabled, requests that encounter an error status code will be resolved with the `response` instead of throwing. This may be useful if you are checking for resource availability and are expecting error responses.\n\n###### agent\n\nType: `object`\n\nAn object representing `http`, `https` and `http2` keys for [`http.Agent`](https://nodejs.org/api/http.html#http_class_http_agent), [`https.Agent`](https://nodejs.org/api/https.html#https_class_https_agent) and [`http2wrapper.Agent`](https://github.com/szmarczak/http2-wrapper#new-http2agentoptions) instance. This is necessary because a request to one protocol might redirect to another. In such a scenario, Got will switch over to the right protocol agent for you.\n\nIf a key is not present, it will default to a global agent.\n\n```js\nconst got = require('got');\nconst HttpAgent = require('agentkeepalive');\nconst {HttpsAgent} = HttpAgent;\n\ngot('https://sindresorhus.com', {\n\tagent: {\n\t\thttp: new HttpAgent(),\n\t\thttps: new HttpsAgent()\n\t}\n});\n```\n\n###### hooks\n\nType: `object<string, Function[]>`\n\nHooks allow modifications during the request lifecycle. Hook functions may be async and are run serially.\n\n###### hooks.init\n\nType: `Function[]`\\\nDefault: `[]`\n\nCalled with plain [request options](#options), right before their normalization. This is especially useful in conjunction with [`got.extend()`](#instances) when the input needs custom handling.\n\nSee the [Request migration guide](documentation/migration-guides.md#breaking-changes) for an example.\n\n**Note #1:** This hook must be synchronous!\\\n**Note #2:** Errors in this hook will be converted into an instances of [`RequestError`](#gotrequesterror).\\\n**Note #3:** The options object may not have a `url` property. To modify it, use a `beforeRequest` hook instead.\n\n###### hooks.beforeRequest\n\nType: `Function[]`\\\nDefault: `[]`\n\nCalled with [normalized](source/core/index.ts) [request options](#options). Got will make no further changes to the request before it is sent. This is especially useful in conjunction with [`got.extend()`](#instances) when you want to create an API client that, for example, uses HMAC-signing.\n\n**Note:** Changing `options.json` or `options.form` has no effect on the request, you should change `options.body` instead. If needed, update the `options.headers` accordingly. Example:\n\n```js\nconst got = require('got');\n\ngot.post({\n\tjson: {payload: 'old'},\n\thooks: {\n\t\tbeforeRequest: [\n\t\t\toptions => {\n\t\t\t\toptions.body = JSON.stringify({payload: 'new'});\n\t\t\t\toptions.headers['content-length'] = options.body.length.toString();\n\t\t\t}\n\t\t]\n\t}\n});\n```\n\n**Tip:** You can override the `request` function by returning a [`ClientRequest`-like](https://nodejs.org/api/http.html#http_class_http_clientrequest) instance or a [`IncomingMessage`-like](https://nodejs.org/api/http.html#http_class_http_incomingmessage) instance. This is very useful when creating a custom cache mechanism.\n\n###### hooks.beforeRedirect\n\nType: `Function[]`\\\nDefault: `[]`\n\nCalled with [normalized](source/core/index.ts) [request options](#options) and the redirect [response](#response). Got will make no further changes to the request. This is especially useful when you want to avoid dead sites. Example:\n\n```js\nconst got = require('got');\n\ngot('https://example.com', {\n\thooks: {\n\t\tbeforeRedirect: [\n\t\t\t(options, response) => {\n\t\t\t\tif (options.hostname === 'deadSite') {\n\t\t\t\t\toptions.hostname = 'fallbackSite';\n\t\t\t\t}\n\t\t\t}\n\t\t]\n\t}\n});\n```\n\n###### hooks.beforeRetry\n\nType: `Function[]`\\\nDefault: `[]`\n\n**Note:** When using streams, this hook is ignored.\n\nCalled with [normalized](source/normalize-arguments.ts) [request options](#options), the error and the retry count. Got will make no further changes to the request. This is especially useful when some extra work is required before the next try. Example:\n\n```js\nconst got = require('got');\n\ngot.post('https://example.com', {\n\thooks: {\n\t\tbeforeRetry: [\n\t\t\t(options, error, retryCount) => {\n\t\t\t\tif (error.response.statusCode === 413) { // Payload too large\n\t\t\t\t\toptions.body = getNewBody();\n\t\t\t\t}\n\t\t\t}\n\t\t]\n\t}\n});\n```\n\n**Note:** When retrying in a `afterResponse` hook, all remaining `beforeRetry` hooks will be called without the `error` and `retryCount` arguments.\n\n###### hooks.afterResponse\n\nType: `Function[]`\\\nDefault: `[]`\n\n**Note:** When using streams, this hook is ignored.\n\nCalled with [response object](#response) and a retry function. Calling the retry function will trigger `beforeRetry` hooks.\n\nEach function should return the response. This is especially useful when you want to refresh an access token. Example:\n\n```js\nconst got = require('got');\n\nconst instance = got.extend({\n\thooks: {\n\t\tafterResponse: [\n\t\t\t(response, retryWithMergedOptions) => {\n\t\t\t\tif (response.statusCode === 401) { // Unauthorized\n\t\t\t\t\tconst updatedOptions = {\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\ttoken: getNewToken() // Refresh the access token\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\t// Save for further requests\n\t\t\t\t\tinstance.defaults.options = got.mergeOptions(instance.defaults.options, updatedOptions);\n\n\t\t\t\t\t// Make a new retry\n\t\t\t\t\treturn retryWithMergedOptions(updatedOptions);\n\t\t\t\t}\n\n\t\t\t\t// No changes otherwise\n\t\t\t\treturn response;\n\t\t\t}\n\t\t],\n\t\tbeforeRetry: [\n\t\t\t(options, error, retryCount) => {\n\t\t\t\t// This will be called on `retryWithMergedOptions(...)`\n\t\t\t}\n\t\t]\n\t},\n\tmutableDefaults: true\n});\n```\n\n###### hooks.beforeError\n\nType: `Function[]`\\\nDefault: `[]`\n\nCalled with an `Error` instance. The error is passed to the hook right before it's thrown. This is especially useful when you want to have more detailed errors.\n\n**Note:** Errors thrown while normalizing input options are thrown directly and not part of this hook.\n\n```js\nconst got = require('got');\n\ngot('https://api.github.com/some-endpoint', {\n\thooks: {\n\t\tbeforeError: [\n\t\t\terror => {\n\t\t\t\tconst {response} = error;\n\t\t\t\tif (response && response.body) {\n\t\t\t\t\terror.name = 'GitHubError';\n\t\t\t\t\terror.message = `${response.body.message} (${response.statusCode})`;\n\t\t\t\t}\n\n\t\t\t\treturn error;\n\t\t\t}\n\t\t]\n\t}\n});\n```\n\n##### pagination\n\nType: `object`\n\n**Note:** We're [looking for feedback](https://github.com/sindresorhus/got/issues/1052), any ideas on how to improve the API are welcome.\n\n###### pagination.transform\n\nType: `Function`\\\nDefault: `response => JSON.parse(response.body)`\n\nA function that transform [`Response`](#response) into an array of items. This is where you should do the parsing.\n\n###### pagination.paginate\n\nType: `Function`\\\nDefault: [`Link` header logic](source/index.ts)\n\nThe function takes three arguments:\n- `response` - The current response object.\n- `allItems` - An array of the emitted items.\n- `currentItems` - Items from the current response.\n\nIt should return an object representing Got options pointing to the next page. The options are merged automatically with the previous request, therefore the options returned `pagination.paginate(...)` must reflect changes only. If there are no more pages, `false` should be returned.\n\nFor example, if you want to stop when the response contains less items than expected, you can use something like this:\n\n```js\nconst got = require('got');\n\n(async () => {\n\tconst limit = 10;\n\n\tconst items = got.paginate('https://example.com/items', {\n\t\tsearchParams: {\n\t\t\tlimit,\n\t\t\toffset: 0\n\t\t},\n\t\tpagination: {\n\t\t\tpaginate: (response, allItems, currentItems) => {\n\t\t\t\tconst previousSearchParams = response.request.options.searchParams;\n\t\t\t\tconst previousOffset = previousSearchParams.get('offset');\n\n\t\t\t\tif (currentItems.length < limit) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tsearchParams: {\n\t\t\t\t\t\t...previousSearchParams,\n\t\t\t\t\t\toffset: Number(previousOffset) + limit,\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t});\n\n\tconsole.log('Items from all pages:', items);\n})();\n```\n\n###### pagination.filter\n\nType: `Function`\\\nDefault: `(item, allItems, currentItems) => true`\n\nChecks whether the item should be emitted or not.\n\n###### pagination.shouldContinue\n\nType: `Function`\\\nDefault: `(item, allItems, currentItems) => true`\n\nChecks whether the pagination should continue.\n\nFor example, if you need to stop **before** emitting an entry with some flag, you should use `(item, allItems, currentItems) => !item.flag`. If you want to stop **after** emitting the entry, you should use `(item, allItems, currentItems) => allItems.some(entry => entry.flag)` instead.\n\n###### pagination.countLimit\n\nType: `number`\\\nDefault: `Infinity`\n\nThe maximum amount of items that should be emitted.\n\n###### pagination.backoff\n\nType: `number`\\\nDefault: `0`\n\nMilliseconds to wait before the next request is triggered.\n\n###### pagination.requestLimit\n\nType: `number`\\\nDefault: `10000`\n\nThe maximum amount of request that should be triggered. [Retries on failure](#retry) are not counted towards this limit.\n\nFor example, it can be helpful during development to avoid an infinite number of requests.\n\n###### pagination.stackAllItems\n\nType: `boolean`\\\nDefault: `true`\n\nDefines how the parameter `allItems` in [pagination.paginate](#pagination.paginate), [pagination.filter](#pagination.filter) and [pagination.shouldContinue](#pagination.shouldContinue) is managed. When set to `false`, the parameter `allItems` is always an empty array.\n\nThis option can be helpful to save on memory usage when working with a large dataset.\n\n##### localAddress\n\nType: `string`\n\nThe IP address used to send the request from.\n\n### Advanced HTTPS API\n\nNote: If the request is not HTTPS, these options will be ignored.\n\n##### https.certificateAuthority\n\nType: `string | Buffer | Array<string | Buffer>`\n\nOverride the default Certificate Authorities ([from Mozilla](https://ccadb-public.secure.force.com/mozilla/IncludedCACertificateReport))\n\n```js\n// Single Certificate Authority\ngot('https://example.com', {\n\thttps: {\n\t\tcertificateAuthority: fs.readFileSync('./my_ca.pem')\n\t}\n});\n```\n\n##### https.key\n\nType: `string | Buffer | Array<string | Buffer> | object[]`\n\nPrivate keys in [PEM](https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail) format.\\\n[PEM](https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail) allows the option of private keys being encrypted. Encrypted keys will be decrypted with `options.https.passphrase`.\\\nMultiple keys with different passphrases can be provided as an array of `{pem: <string | Buffer>, passphrase: <string>}`\n\n##### https.certificate\n\nType: `string | Buffer | (string | Buffer)[]`\n\n[Certificate chains](https://en.wikipedia.org/wiki/X.509#Certificate_chains_and_cross-certification) in [PEM](https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail) format.\\\nOne cert chain should be provided per private key (`options.https.key`).\\\nWhen providing multiple cert chains, they do not have to be in the same order as their private keys in `options.https.key`.\\\nIf the intermediate certificates are not provided, the peer will not be able to validate the certificate, and the handshake will fail.\n\n##### https.passphrase\n\nType: `string`\n\nThe passphrase to decrypt the `options.https.key` (if different keys have different passphrases refer to `options.https.key` documentation).\n\n##### https.pfx\n\nType: `string | Buffer | Array<string | Buffer | object>`\n\n[PFX or PKCS12](https://en.wikipedia.org/wiki/PKCS_12) encoded private key and certificate chain. Using `options.https.pfx` is an alternative to providing `options.https.key` and `options.https.certificate` individually. A PFX is usually encrypted, and if it is, `options.https.passphrase` will be used to decrypt it.\n\nMultiple PFX's can be be provided as an array of unencrypted buffers or an array of objects like:\n\n```ts\n{\n\tbuffer: string | Buffer,\n\tpassphrase?: string\n}\n```\n\nThis object form can only occur in an array. If the provided buffers are encrypted, `object.passphrase` can be used to decrypt them. If `object.passphrase` is not provided, `options.https.passphrase` will be used for decryption.\n\n##### Examples for `https.key`, `https.certificate`, `https.passphrase`, and `https.pfx`\n\n```js\n// Single key with certificate\ngot('https://example.com', {\n\thttps: {\n\t\tkey: fs.readFileSync('./client_key.pem'),\n\t\tcertificate: fs.readFileSync('./client_cert.pem')\n\t}\n});\n\n// Multiple keys with certificates (out of order)\ngot('https://example.com', {\n\thttps: {\n\t\tkey: [\n\t\t\tfs.readFileSync('./client_key1.pem'),\n\t\t\tfs.readFileSync('./client_key2.pem')\n\t\t],\n\t\tcertificate: [\n\t\t\tfs.readFileSync('./client_cert2.pem'),\n\t\t\tfs.readFileSync('./client_cert1.pem')\n\t\t]\n\t}\n});\n\n// Single key with passphrase\ngot('https://example.com', {\n\thttps: {\n\t\tkey: fs.readFileSync('./client_key.pem'),\n\t\tcertificate: fs.readFileSync('./client_cert.pem'),\n\t\tpassphrase: 'client_key_passphrase'\n\t}\n});\n\n// Multiple keys with different passphrases\ngot('https://example.com', {\n\thttps: {\n\t\tkey: [\n\t\t\t{pem: fs.readFileSync('./client_key1.pem'), passphrase: 'passphrase1'},\n\t\t\t{pem: fs.readFileSync('./client_key2.pem'), passphrase: 'passphrase2'},\n\t\t],\n\t\tcertificate: [\n\t\t\tfs.readFileSync('./client_cert1.pem'),\n\t\t\tfs.readFileSync('./client_cert2.pem')\n\t\t]\n\t}\n});\n\n// Single encrypted PFX with passphrase\ngot('https://example.com', {\n\thttps: {\n\t\tpfx: fs.readFileSync('./fake.pfx'),\n\t\tpassphrase: 'passphrase'\n\t}\n});\n\n// Multiple encrypted PFX's with different passphrases\ngot('https://example.com', {\n\thttps: {\n\t\tpfx: [\n\t\t\t{\n\t\t\t\tbuffer: fs.readFileSync('./key1.pfx'),\n\t\t\t\tpassphrase: 'passphrase1'\n\t\t\t},\n\t\t\t{\n\t\t\t\tbuffer: fs.readFileSync('./key2.pfx'),\n\t\t\t\tpassphrase: 'passphrase2'\n\t\t\t}\n\t\t]\n\t}\n});\n\n// Multiple encrypted PFX's with single passphrase\ngot('https://example.com', {\n\thttps: {\n\t\tpassphrase: 'passphrase',\n\t\tpfx: [\n\t\t\t{\n\t\t\t\tbuffer: fs.readFileSync('./key1.pfx')\n\t\t\t},\n\t\t\t{\n\t\t\t\tbuffer: fs.readFileSync('./key2.pfx')\n\t\t\t}\n\t\t]\n\t}\n});\n```\n\n##### https.rejectUnauthorized\n\nType: `boolean`\\\nDefault: `true`\n\nIf set to `false`, all invalid SSL certificates will be ignored and no error will be thrown.\\\nIf set to `true`, it will throw an error whenever an invalid SSL certificate is detected.\n\nWe strongly recommend to have this set to `true` for security reasons.\n\n```js\nconst got = require('got');\n\n(async () => {\n\t// Correct:\n\tawait got('https://example.com', {\n\t\thttps: {\n\t\t\trejectUnauthorized: true\n\t\t}\n\t});\n\n\t// You can disable it when developing an HTTPS app:\n\tawait got('https://localhost', {\n\t\thttps: {\n\t\t\trejectUnauthorized: false\n\t\t}\n\t});\n\n\t// Never do this:\n\tawait got('https://example.com', {\n\t\thttps: {\n\t\t\trejectUnauthorized: false\n\t\t}\n\t});\n```\n\n##### https.checkServerIdentity\n\nType: `Function`\\\nSignature: `(hostname: string, certificate: DetailedPeerCertificate) => Error | undefined`\\\nDefault: `tls.checkServerIdentity` (from the `tls` module)\n\nThis function enable a custom check of the certificate.\\\nNote: In order to have the function called the certificate must not be `expired`, `self-signed` or with an `untrusted-root`.\\\nThe function parameters are:\n- `hostname`: The server hostname (used when connecting)\n- `certificate`: The server certificate\n\nThe function must return `undefined` if the check succeeded or an `Error` if it failed.\n\n```js\nawait got('https://example.com', {\n\thttps: {\n\t\tcheckServerIdentity: (hostname, certificate) => {\n\t\t\tif (hostname === 'example.com') {\n\t\t\t\treturn; // Certificate OK\n\t\t\t}\n\n\t\t\treturn new Error('Invalid Hostname'); // Certificate NOT OK\n\t\t}\n\t}\n});\n```\n\n#### Response\n\nThe response object will typically be a [Node.js HTTP response stream](https://nodejs.org/api/http.html#http_class_http_incomingmessage), however, if returned from the cache it will be a [response-like object](https://github.com/lukechilds/responselike) which behaves in the same way.\n\n##### request\n\nType: `object`\n\n**Note:** This is not a [http.ClientRequest](https://nodejs.org/api/http.html#http_class_http_clientrequest).\n\n- `options` - The Got options that were set on this request.\n\n##### body\n\nType: `string | object | Buffer` *(Depending on `options.responseType`)*\n\nThe result of the request.\n\n##### rawBody\n\nType: `Buffer`\n\nThe raw result of the request.\n\n##### url\n\nType: `string`\n\nThe request URL or the final URL after redirects.\n\n##### ip\n\nType: `string`\n\nThe remote IP address.\n\n**Note:** Not available when the response is cached. This is hopefully a temporary limitation, see [lukechilds/cacheable-request#86](https://github.com/lukechilds/cacheable-request/issues/86).\n\n##### requestUrl\n\nType: `string`\n\nThe original request URL.\n\n##### timings\n\nType: `object`\n\nThe object contains the following properties:\n\n- `start` - Time when the request started.\n- `socket` - Time when a socket was assigned to the request.\n- `lookup` - Time when the DNS lookup finished.\n- `connect` - Time when the socket successfully connected.\n- `secureConnect` - Time when the socket securely connected.\n- `upload` - Time when the request finished uploading.\n- `response` - Time when the request fired `response` event.\n- `end` - Time when the response fired `end` event.\n- `error` - Time when the request fired `error` event.\n- `abort` - Time when the request fired `abort` event.\n- `phases`\n\t- `wait` - `timings.socket - timings.start`\n\t- `dns` - `timings.lookup - timings.socket`\n\t- `tcp` - `timings.connect - timings.lookup`\n\t- `tls` - `timings.secureConnect - timings.connect`\n\t- `request` - `timings.upload - (timings.secureConnect || timings.connect)`\n\t- `firstByte` - `timings.response - timings.upload`\n\t- `download` - `timings.end - timings.response`\n\t- `total` - `(timings.end || timings.error || timings.abort) - timings.start`\n\nIf something has not been measured yet, it will be `undefined`.\n\n**Note:** The time is a `number` representing the milliseconds elapsed since the UNIX epoch.\n\n##### isFromCache\n\nType: `boolean`\n\nWhether the response was retrieved from the cache.\n\n##### redirectUrls\n\nType: `string[]`\n\nThe redirect URLs.\n\n##### retryCount\n\nType: `number`\n\nThe number of times the request was retried.\n\n#### Streams\n\n**Note:** Progress events, redirect events and request/response events can also be used with promises.\n\n**Note:** To access `response.isFromCache` you need to use `got.stream(url, options).isFromCache`. The value will be undefined until the `response` event.\n\n#### got.stream(url, options?)\n\nSets `options.isStream` to `true`.\n\nReturns a [duplex stream](https://nodejs.org/api/stream.html#stream_class_stream_duplex) with additional events:\n\n##### .on('request', request)\n\n`request` event to get the request object of the request.\n\n**Tip:** You can use `request` event to abort request:\n\n```js\ngot.stream('https://github.com')\n\t.on('request', request => setTimeout(() => request.destroy(), 50));\n```\n\n##### .on('response', response)\n\nThe `response` event to get the response object of the final request.\n\n##### .on('redirect', response, nextOptions)\n\nThe `redirect` event to get the response object of a redirect. The second argument is options for the next request to the redirect location.\n\n##### .on('uploadProgress', progress)\n##### .uploadProgress\n##### .on('downloadProgress', progress)\n##### .downloadProgress\n\nProgress events for uploading (sending a request) and downloading (receiving a response). The `progress` argument is an object like:\n\n```js\n{\n\tpercent: 0.1,\n\ttransferred: 1024,\n\ttotal: 10240\n}\n```\n\nIf the `content-length` header is missing, `total` will be `undefined`.\n\n```js\n(async () => {\n\tconst response = await got('https://sindresorhus.com')\n\t\t.on('downloadProgress', progress => {\n\t\t\t// Report download progress\n\t\t})\n\t\t.on('uploadProgress', progress => {\n\t\t\t// Report upload progress\n\t\t});\n\n\tconsole.log(response);\n})();\n```\n\n##### .once('retry', retryCount, error)\n\nTo enable retrying on a Got stream, it is required to have a `retry` handler attached.\\\nWhen this event is emitted, you should reset the stream you were writing to and prepare the body again.\n\nSee the [`retry`](#retry-stream) option for an example implementation.\n\n##### .ip\n\nType: `string`\n\nThe remote IP address.\n\n##### .aborted\n\nType: `boolean`\n\nIndicates whether the request has been aborted or not.\n\n##### .timings\n\nThe same as `response.timings`.\n\n##### .isFromCache\n\nThe same as `response.isFromCache`.\n\n##### .socket\n\nThe same as `response.socket`.\n\n##### .on('error', error)\n\nThe emitted `error` is an instance of [`RequestError`](#gotrequesterror).\n\n#### Pagination\n\n#### got.paginate(url, options?)\n#### got.paginate.each(url, options?)\n\nReturns an async iterator:\n\n```js\n(async () => {\n\tconst countLimit = 10;\n\n\tconst pagination = got.paginate('https://api.github.com/repos/sindresorhus/got/commits', {\n\t\tpagination: {countLimit}\n\t});\n\n\tconsole.log(`Printing latest ${countLimit} Got commits (newest to oldest):`);\n\n\tfor await (const commitData of pagination) {\n\t\tconsole.log(commitData.commit.message);\n\t}\n})();\n```\n\nSee [`options.pagination`](#pagination) for more pagination options.\n\n#### got.paginate.all(url, options?)\n\nReturns a Promise for an array of all results:\n\n```js\n(async () => {\n\tconst countLimit = 10;\n\n\tconst results = await got.paginate.all('https://api.github.com/repos/sindresorhus/got/commits', {\n\t\tpagination: {countLimit}\n\t});\n\n\tconsole.log(`Printing latest ${countLimit} Got commits (newest to oldest):`);\n\tconsole.log(results);\n})();\n```\n\nSee [`options.pagination`](#pagination) for more pagination options.\n\n#### got.get(url, options?)\n#### got.post(url, options?)\n#### got.put(url, options?)\n#### got.patch(url, options?)\n#### got.head(url, options?)\n#### got.delete(url, options?)\n\nSets [`options.method`](#method) to the method name and makes a request.\n\n### Instances\n\n#### got.extend(...options)\n\nConfigure 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.\n\n```js\nconst client = got.extend({\n\tprefixUrl: 'https://example.com',\n\theaders: {\n\t\t'x-unicorn': 'rainbow'\n\t}\n});\n\nclient.get('demo');\n\n/* HTTP Request =>\n * GET /demo HTTP/1.1\n * Host: example.com\n * x-unicorn: rainbow\n */\n```\n\n```js\n(async () => {\n\tconst client = got.extend({\n\t\tprefixUrl: 'httpbin.org',\n\t\theaders: {\n\t\t\t'x-foo': 'bar'\n\t\t}\n\t});\n\tconst {headers} = await client.get('headers').json();\n\t//=> headers['x-foo'] === 'bar'\n\n\tconst jsonClient = client.extend({\n\t\tresponseType: 'json',\n\t\tresolveBodyOnly: true,\n\t\theaders: {\n\t\t\t'x-baz': 'qux'\n\t\t}\n\t});\n\tconst {headers: headers2} = await jsonClient.get('headers');\n\t//=> headers2['x-foo'] === 'bar'\n\t//=> headers2['x-baz'] === 'qux'\n})();\n```\n\nAdditionally, `got.extend()` accepts two properties from the `defaults` object: `mutableDefaults` and `handlers`. Example:\n\n```js\n// You can now modify `mutableGot.defaults.options`.\nconst mutableGot = got.extend({mutableDefaults: true});\n\nconst mergedHandlers = got.extend({\n\thandlers: [\n\t\t(options, next) => {\n\t\t\tdelete options.headers.referer;\n\n\t\t\treturn next(options);\n\t\t}\n\t]\n});\n```\n\n**Note:** Handlers can be asynchronous. The recommended approach is:\n\n```js\nconst handler = (options, next) => {\n\tif (options.isStream) {\n\t\t// It's a Stream\n\t\treturn next(options);\n\t}\n\n\t// It's a Promise\n\treturn (async () => {\n\t\ttry {\n\t\t\tconst response = await next(options);\n\t\t\tresponse.yourOwnProperty = true;\n\t\t\treturn response;\n\t\t} catch (error) {\n\t\t\t// Every error will be replaced by this one.\n\t\t\t// Before you receive any error here,\n\t\t\t// it will be passed to the `beforeError` hooks first.\n\t\t\t// Note: this one won't be passed to `beforeError` hook. It's final.\n\t\t\tthrow new Error('Your very own error.');\n\t\t}\n\t})();\n};\n\nconst instance = got.extend({handlers: [handler]});\n```\n\n#### got.extend(...options, ...instances, ...)\n\nMerges many instances into a single one:\n- options are merged using [`got.mergeOptions()`](#gotmergeoptionsparentoptions-newoptions) (including hooks),\n- handlers are stored in an array (you can access them through `instance.defaults.handlers`).\n\n```js\nconst a = {headers: {cat: 'meow'}};\nconst b = got.extend({\n\toptions: {\n\t\theaders: {\n\t\t\tcow: 'moo'\n\t\t}\n\t}\n});\n\n// The same as `got.extend(a).extend(b)`.\n// Note `a` is options and `b` is an instance.\ngot.extend(a, b);\n//=> {headers: {cat: 'meow', cow: 'moo'}}\n```\n\n#### got.mergeOptions(parent, ...sources)\n\nExtends parent options. 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:\n\n```js\nconst a = {headers: {cat: 'meow', wolf: ['bark', 'wrrr']}};\nconst b = {headers: {cow: 'moo', wolf: ['auuu']}};\n\n{...a, ...b}            // => {headers: {cow: 'moo', wolf: ['auuu']}}\ngot.mergeOptions(a, b)  // => {headers: {cat: 'meow', cow: 'moo', wolf: ['auuu']}}\n```\n\n**Note:** Only Got options are merged! Custom user options should be defined via [`options.context`](#context).\n\nOptions are deeply merged to a new object. The value of each key is determined as follows:\n\n- If the new property is not defined, the old value is used.\n- If the new property is explicitly set to `undefined`:\n\t- If the parent property is a plain `object`, the parent value is deeply cloned.\n\t- Otherwise, `undefined` is used.\n- If the parent value is an instance of `URLSearchParams`:\n\t- If the new value is a `string`, an `object` or an instance of `URLSearchParams`, a new `URLSearchParams` instance is created. The values are merged using [`urlSearchParams.append(key, value)`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams/append). The keys defined in the new value override the keys defined in the parent value. Please note that `null` values point to an empty string and `undefined` values will exclude the entry.\n\t- Otherwise, the only available value is `undefined`.\n- If the new property is a plain `object`:\n\t- If the parent property is a plain `object` too, both values are merged recursively into a new `object`.\n\t- Otherwise, only the new value is deeply cloned.\n- If the new property is an `Array`, it overwrites the old one with a deep clone of the new property.\n- Properties that are not enumerable, such as `context`, `body`, `json`, and `form`, will not be merged.\n- Otherwise, the new value is assigned to the key.\n\n```js\nconst a = {json: {cat: 'meow'}};\nconst b = {json: {cow: 'moo'}};\n\ngot.mergeOptions(a, b);\n//=> {json: {cow: 'moo'}}\n```\n\n#### got.defaults\n\nType: `object`\n\nThe Got defaults used in that instance.\n\n##### [options](#options)\n\n##### handlers\n\nType: `Function[]`\\\nDefault: `[]`\n\nAn array of functions. You execute them directly by calling `got()`. They are some sort of \"global hooks\" - these functions are called first. The last handler (*it's hidden*) is either [`asPromise`](source/core/as-promise/index.ts) or [`asStream`](source/core/index.ts), depending on the `options.isStream` property.\n\nEach handler takes two arguments:\n\n###### [options](#options)\n\n###### next()\n\nReturns a `Promise` or a `Stream` depending on [`options.isStream`](#isstream).\n\n```js\nconst settings = {\n\thandlers: [\n\t\t(options, next) => {\n\t\t\tif (options.isStream) {\n\t\t\t\t// It's a Stream, so we can perform stream-specific actions on it\n\t\t\t\treturn next(options)\n\t\t\t\t\t.on('request', request => {\n\t\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\t\trequest.abort();\n\t\t\t\t\t\t}, 50);\n\t\t\t\t\t});\n\t\t\t}\n\n\t\t\t// It's a Promise\n\t\t\treturn next(options);\n\t\t}\n\t],\n\toptions: got.mergeOptions(got.defaults.options, {\n\t\tresponseType: 'json'\n\t})\n};\n\nconst jsonGot = got.extend(settings);\n```\n\n##### mutableDefaults\n\nType: `boolean`\\\nDefault: `false`\n\nA read-only boolean describing whether the defaults are mutable or not. If set to `true`, you can [update headers over time](#hooksafterresponse), for example, update an access token when it expires.\n\n## Types\n\nGot exports some handy TypeScript types and interfaces. See the type definition for all the exported types.\n\n### Got\n\nTypeScript will automatically infer types for Got instances, but in case you want to define something like dependencies, you can import the available types directly from Got.\n\n```ts\nimport {GotRequestFunction} from 'got';\n\ninterface Dependencies {\n\treadonly post: GotRequestFunction\n}\n```\n\n### Hooks\n\nWhen writing hooks, you can refer to their types to keep your interfaces consistent.\n\n```ts\nimport {BeforeRequestHook} from 'got';\n\nconst addAccessToken = (accessToken: string): BeforeRequestHook => options => {\n\toptions.path = `${options.path}?access_token=${accessToken}`;\n}\n```\n\n## Errors\n\nEach error contains an `options` property which are the options Got used to create a request - just to make debugging easier.\\\nAdditionaly, the errors may have `request` (Got Stream) and `response` (Got Response) properties depending on which phase of the request failed.\n\n#### got.RequestError\n\nWhen a request fails. Contains a `code` property with error class code, like `ECONNREFUSED`. If there is no specific code supplied, `code` defaults to `ERR_GOT_REQUEST_ERROR`. All the errors below inherit this one.\n\n#### got.CacheError\n\nWhen a cache method fails, for example, if the database goes down or there's a filesystem error. Contains a `code` property with `ERR_CACHE_ACCESS` or a more specific failure code.\n\n#### got.ReadError\n\nWhen reading from response stream fails. Contains a `code` property with `ERR_READING_RESPONSE_STREAM` or a more specific failure code.\n\n#### got.ParseError\n\nWhen server response code is 2xx, and parsing body fails. Includes a `response` property. Contains a `code` property with `ERR_BODY_PARSE_FAILURE` or a more specific failure code.\n\n#### got.UploadError\n\nWhen the request body is a stream and an error occurs while reading from that stream. Contains a `code` property with `ERR_UPLOAD` or a more specific failure code.\n\n#### got.HTTPError\n\nWhen the server response code is not 2xx nor 3xx if `options.followRedirect` is `true`, but always except for 304. Includes a `response` property. Contains a `code` property with `ERR_NON_2XX_3XX_RESPONSE` or a more specific failure code.\n\n\n#### got.MaxRedirectsError\n\nWhen the server redirects you more than ten times. Includes a `response` property. Contains a `code` property with `ERR_TOO_MANY_REDIRECTS`.\n\n#### got.UnsupportedProtocolError\n\nWhen given an unsupported protocol. Contains a `code` property with `ERR_UNSUPPORTED_PROTOCOL`.\n\n#### got.TimeoutError\n\nWhen the request is aborted due to a [timeout](#timeout). Includes an `event` and `timings` property. Contains a `code` property with `ETIMEDOUT`.\n\n#### got.CancelError\n\nWhen the request is aborted with `.cancel()`. Contains a `code` property with `ERR_CANCELED`.\n\n## Aborting the request\n\nThe promise returned by Got has a [`.cancel()`](https://github.com/sindresorhus/p-cancelable) method which when called, aborts the request.\n\n```js\n(async () => {\n\tconst request = got(url, options);\n\n\t// …\n\n\t// In another part of the code\n\tif (something) {\n\t\trequest.cancel();\n\t}\n\n\t// …\n\n\ttry {\n\t\tawait request;\n\t} catch (error) {\n\t\tif (request.isCanceled) { // Or `error instanceof got.CancelError`\n\t\t\t// Handle cancelation\n\t\t}\n\n\t\t// Handle other errors\n\t}\n})();\n```\n\nWhen using hooks, simply throw an error to abort the request.\n\n```js\nconst got = require('got');\n\n(async () => {\n\tconst request = got(url, {\n\t\thooks: {\n\t\t\tbeforeRequest: [\n\t\t\t\t() => {\n\t\t\t\t\tthrow new Error('Oops. Request canceled.');\n\t\t\t\t}\n\t\t\t]\n\t\t}\n\t});\n\n\ttry {\n\t\tawait request;\n\t} catch (error) {\n\t\t// …\n\t}\n})();\n```\n\nTo abort the Got Stream request, just call `stream.destroy()`.\n\n```js\nconst got = require('got');\n\nconst stream = got.stream(url);\nstream.destroy();\n```\n\n<a name=\"cache-adapters\"></a>\n## Cache\n\nGot implements [RFC 7234](https://httpwg.org/specs/rfc7234.html) compliant HTTP caching which works out of the box in-memory and is easily pluggable with a wide range of storage adapters. Fresh cache entries are served directly from the cache, and stale cache entries are revalidated with `If-None-Match`/`If-Modified-Since` headers. You can read more about the underlying cache behavior in the [`cacheable-request` documentation](https://github.com/lukechilds/cacheable-request). For DNS cache, Got uses [`cacheable-lookup`](https://github.com/szmarczak/cacheable-lookup).\n\nYou can use the JavaScript `Map` type as an in-memory cache:\n\n```js\nconst got = require('got');\n\nconst map = new Map();\n\n(async () => {\n\t\tlet response = await got('https://sindresorhus.com', {cache: map});\n\t\tconsole.log(response.isFromCache);\n\t\t//=> false\n\n\t\tresponse = await got('https://sindresorhus.com', {cache: map});\n\t\tconsole.log(response.isFromCache);\n\t\t//=> true\n})();\n```\n\nGot uses [Keyv](https://github.com/lukechilds/keyv) internally to support a wide range of storage adapters. For something more scalable you could use an [official Keyv storage adapter](https://github.com/lukechilds/keyv#official-storage-adapters):\n\n```\n$ npm install @keyv/redis\n```\n\n```js\nconst got = require('got');\nconst KeyvRedis = require('@keyv/redis');\n\nconst redis = new KeyvRedis('redis://user:pass@localhost:6379');\n\ngot('https://sindresorhus.com', {cache: redis});\n```\n\nGot supports anything that follows the Map API, so it's easy to write your own storage adapter or use a third-party solution.\n\nFor example, the following are all valid storage adapters:\n\n```js\nconst storageAdapter = new Map();\n// Or\nconst storageAdapter = require('./my-storage-adapter');\n// Or\nconst QuickLRU = require('quick-lru');\nconst storageAdapter = new QuickLRU({maxSize: 1000});\n\ngot('https://sindresorhus.com', {cache: storageAdapter});\n```\n\nView the [Keyv docs](https://github.com/lukechilds/keyv) for more information on how to use storage adapters.\n\n## Proxies\n\nYou can use the [`tunnel`](https://github.com/koichik/node-tunnel) package with the `agent` option to work with proxies:\n\n```js\nconst got = require('got');\nconst tunnel = require('tunnel');\n\ngot('https://sindresorhus.com', {\n\tagent: {\n\t\thttps: tunnel.httpsOverHttp({\n\t\t\tproxy: {\n\t\t\t\thost: 'localhost'\n\t\t\t}\n\t\t})\n\t}\n});\n```\n\nOtherwise, you can use the [`hpagent`](https://github.com/delvedor/hpagent) package, which keeps the internal sockets alive to be reused.\n\n```js\nconst got = require('got');\nconst {HttpsProxyAgent} = require('hpagent');\n\ngot('https://sindresorhus.com', {\n\tagent: {\n\t\thttps: new HttpsProxyAgent({\n\t\t\tkeepAlive: true,\n\t\t\tkeepAliveMsecs: 1000,\n\t\t\tmaxSockets: 256,\n\t\t\tmaxFreeSockets: 256,\n\t\t\tscheduling: 'lifo',\n\t\t\tproxy: 'https://localhost:8080'\n\t\t})\n\t}\n});\n```\n\nAlternatively, use [`global-agent`](https://github.com/gajus/global-agent) to configure a global proxy for all HTTP/HTTPS traffic in your program.\n\nRead the [`http2-wrapper`](https://github.com/szmarczak/http2-wrapper/#proxy-support) docs to learn about proxying for HTTP/2.\n\n## Cookies\n\nYou can use the [`tough-cookie`](https://github.com/salesforce/tough-cookie) package:\n\n```js\nconst {promisify} = require('util');\nconst got = require('got');\nconst {CookieJar} = require('tough-cookie');\n\n(async () => {\n\tconst cookieJar = new CookieJar();\n\tconst setCookie = promisify(cookieJar.setCookie.bind(cookieJar));\n\n\tawait setCookie('foo=bar', 'https://example.com');\n\tawait got('https://example.com', {cookieJar});\n})();\n```\n\n## Form data\n\nYou can use the [`form-data`](https://github.com/form-data/form-data) package to create POST request with form data:\n\n```js\nconst fs = require('fs');\nconst got = require('got');\nconst FormData = require('form-data');\n\nconst form = new FormData();\n\nform.append('my_file', fs.createReadStream('/foo/bar.jpg'));\n\ngot.post('https://example.com', {\n\tbody: form\n});\n```\n\n## OAuth\n\nYou can use the [`oauth-1.0a`](https://github.com/ddo/oauth-1.0a) package to create a signed OAuth request:\n\n```js\nconst got = require('got');\nconst crypto  = require('crypto');\nconst OAuth = require('oauth-1.0a');\n\nconst oauth = OAuth({\n\tconsumer: {\n\t\tkey: process.env.CONSUMER_KEY,\n\t\tsecret: process.env.CONSUMER_SECRET\n\t},\n\tsignature_method: 'HMAC-SHA1',\n\thash_function: (baseString, key) => crypto.createHmac('sha1', key).update(baseString).digest('base64')\n});\n\nconst token = {\n\tkey: process.env.ACCESS_TOKEN,\n\tsecret: process.env.ACCESS_TOKEN_SECRET\n};\n\nconst url = 'https://api.twitter.com/1.1/statuses/home_timeline.json';\n\ngot(url, {\n\theaders: oauth.toHeader(oauth.authorize({url, method: 'GET'}, token)),\n\tresponseType: 'json'\n});\n```\n\n## Unix Domain Sockets\n\nRequests can also be sent via [unix domain sockets](http://serverfault.com/questions/124517/whats-the-difference-between-unix-socket-and-tcp-ip-socket). Use the following URL scheme: `PROTOCOL://unix:SOCKET:PATH`.\n\n- `PROTOCOL` - `http` or `https` *(optional)*\n- `SOCKET` - Absolute path to a unix domain socket, for example: `/var/run/docker.sock`\n- `PATH` - Request path, for example: `/v2/keys`\n\n```js\nconst got = require('got');\n\ngot('http://unix:/var/run/docker.sock:/containers/json');\n\n// Or without protocol (HTTP by default)\ngot('unix:/var/run/docker.sock:/containers/json');\n```\n\n## AWS\n\nRequests to AWS services need to have their headers signed. This can be accomplished by using the [`got4aws`](https://www.npmjs.com/package/got4aws) package. This is an example for querying an [\"API Gateway\"](https://docs.aws.amazon.com/apigateway/api-reference/signing-requests/) with a signed request.\n\n```js\nconst got4aws = require('got4aws');;\n\nconst awsClient = got4aws();\n\nconst response = await awsClient('https://<api-id>.execute-api.<api-region>.amazonaws.com/<stage>/endpoint/path', {\n\t// Request-specific options\n});\n```\n\n## Testing\n\nYou can test your requests by using the [`nock`](https://github.com/node-nock/nock) package to mock an endpoint:\n\n```js\nconst got = require('got');\nconst nock = require('nock');\n\nnock('https://sindresorhus.com')\n\t.get('/')\n\t.reply(200, 'Hello world!');\n\n(async () => {\n\tconst response = await got('https://sindresorhus.com');\n\tconsole.log(response.body);\n\t//=> 'Hello world!'\n})();\n```\n\nBear in mind, that by default `nock` mocks only one request. Got will [retry](#retry) on failed requests by default, causing a `No match for request ...` error. The solution is to either disable retrying (set `options.retry` to `0`) or call `.persist()` on the mocked request.\n\n```js\nconst got = require('got');\nconst nock = require('nock');\n\nconst scope = nock('https://sindresorhus.com')\n\t.get('/')\n\t.reply(500, 'Internal server error')\n\t.persist();\n\n(async () => {\n\ttry {\n\t\tawait got('https://sindresorhus.com')\n\t} catch (error) {\n\t\tconsole.log(error.response.body);\n\t\t//=> 'Internal server error'\n\n\t\tconsole.log(error.response.retryCount);\n\t\t//=> 2\n\t}\n\n\tscope.persist(false);\n})();\n```\n\nFor real integration testing we recommend using [`ava`](https://github.com/avajs/ava) with [`create-test-server`](https://github.com/lukechilds/create-test-server). We're using a macro so we don't have to `server.listen()` and `server.close()` every test. Take a look at one of our tests:\n\n```js\ntest('retry function gets iteration count', withServer, async (t, server, got) => {\n\tlet knocks = 0;\n\tserver.get('/', (request, response) => {\n\t\tif (knocks++ === 1) {\n\t\t\tresponse.end('who`s there?');\n\t\t}\n\t});\n\n\tawait got({\n\t\tretry: {\n\t\t\tcalculateDelay: ({attemptCount}) => {\n\t\t\t\tt.true(is.number(attemptCount));\n\t\t\t\treturn attemptCount < 2 ? 1 : 0;\n\t\t\t}\n\t\t}\n\t});\n});\n```\n\n## Tips\n\n### JSON mode\n\nTo pass an object as the body, you need to use the `json` option. It will be stringified using `JSON.stringify`. Example:\n\n```js\nconst got = require('got');\n\n(async () => {\n\tconst {body} = await got.post('https://httpbin.org/anything', {\n\t\tjson: {\n\t\t\thello: 'world'\n\t\t},\n\t\tresponseType: 'json'\n\t});\n\n\tconsole.log(body.data);\n\t//=> '{\"hello\":\"world\"}'\n})();\n```\n\nTo receive a JSON body you can either set `responseType` option to `json` or use `promise.json()`. Example:\n\n```js\nconst got = require('got');\n\n(async () => {\n\tconst body = await got.post('https://httpbin.org/anything', {\n\t\tjson: {\n\t\t\thello: 'world'\n\t\t}\n\t}).json();\n\n\tconsole.log(body);\n\t//=> {…}\n})();\n```\n\n### User Agent\n\nIt's a good idea to set the `'user-agent'` header so the provider can more easily see how their resource is used. By default, it's the URL to this repo. You can omit this header by setting it to `undefined`.\n\n```js\nconst got = require('got');\nconst pkg = require('./package.json');\n\ngot('https://sindresorhus.com', {\n\theaders: {\n\t\t'user-agent': `my-package/${pkg.version} (https://github.com/username/my-package)`\n\t}\n});\n\ngot('https://sindresorhus.com', {\n\theaders: {\n\t\t'user-agent': undefined\n\t}\n});\n```\n\n### 304 Responses\n\nBear in mind; if you send an `if-modified-since` header and receive a `304 Not Modified` response, the body will be empty. It's your responsibility to cache and retrieve the body contents.\n\n### Custom endpoints\n\nUse `got.extend()` to make it nicer to work with REST APIs. Especially if you use the `prefixUrl` option.\n\n```js\nconst got = require('got');\nconst pkg = require('./package.json');\n\nconst custom = ","readmeFilename":""}