got

  • Version 11.8.2
  • Published
  • 266 kB
  • 11 dependencies
  • MIT license

Install

npm i got
yarn add got
pnpm add got

Overview

Human-friendly and powerful HTTP request library for Node.js

Index

Variables

Functions

Classes

Interfaces

Type Aliases

Namespaces

Variables

variable defaultHandler

const defaultHandler: HandlerFunction;

    variable got

    const got: Got;

      variable kIsNormalizedAlready

      const kIsNormalizedAlready: Symbol;

        variable knownHookEvents

        const knownHookEvents: HookEvent[];

          variable withoutBody

          const withoutBody: ReadonlySet<string>;

            Functions

            function setNonEnumerableProperties

            setNonEnumerableProperties: (
            sources: Array<Options | Defaults | undefined>,
            to: Options
            ) => void;

              Classes

              class CacheError

              class CacheError extends RequestError {}
              • An error to be thrown when a cache method fails. For example, if the database goes down or there's a filesystem error.

              constructor

              constructor(error: any, request: Request);

                property request

                readonly request: Request;

                  class CancelError

                  class CancelError extends RequestError {}
                  • An error to be thrown when the request is aborted with .cancel().

                  constructor

                  constructor(request: Request);

                    property isCanceled

                    readonly isCanceled: boolean;

                      property response

                      readonly response: Response<unknown>;

                        class HTTPError

                        class HTTPError extends RequestError {}
                        • An error to be thrown when the server response code is not 2xx nor 3xx if options.followRedirect is true, but always except for 304. Includes a response property.

                        constructor

                        constructor(response: Response<unknown>);

                          property request

                          readonly request: Request;

                            property response

                            readonly response: Response<unknown>;

                              property timings

                              readonly timings: any;

                                class MaxRedirectsError

                                class MaxRedirectsError extends RequestError {}
                                • An error to be thrown when the server redirects you more than ten times. Includes a response property.

                                constructor

                                constructor(request: Request);

                                  property request

                                  readonly request: Request;

                                    property response

                                    readonly response: Response<unknown>;

                                      property timings

                                      readonly timings: any;

                                        class ParseError

                                        class ParseError extends RequestError {}
                                        • An error to be thrown when server response code is 2xx, and parsing body fails. Includes a response property.

                                        constructor

                                        constructor(error: Error, response: Response<unknown>);

                                          property response

                                          readonly response: Response<unknown>;

                                            class ReadError

                                            class ReadError extends RequestError {}
                                            • An error to be thrown when reading from response stream fails.

                                            constructor

                                            constructor(error: any, request: Request);

                                              property request

                                              readonly request: Request;

                                                property response

                                                readonly response: Response<unknown>;

                                                  property timings

                                                  readonly timings: any;

                                                    class RequestError

                                                    class RequestError extends Error {}
                                                    • An error to be thrown when a request fails. Contains a code property with error class code, like ECONNREFUSED.

                                                    constructor

                                                    constructor(
                                                    message: string,
                                                    error: Partial<any>,
                                                    self: NormalizedOptions | Request
                                                    );

                                                      property code

                                                      code?: string;

                                                        property options

                                                        readonly options: NormalizedOptions;

                                                          property request

                                                          readonly request?: Request;

                                                            property response

                                                            readonly response?: Response<unknown>;

                                                              property stack

                                                              stack: string;

                                                                property timings

                                                                readonly timings?: any;

                                                                  class TimeoutError

                                                                  class TimeoutError extends RequestError {}
                                                                  • An error to be thrown when the request is aborted due to a timeout. Includes an event and timings property.

                                                                  constructor

                                                                  constructor(error: TimedOutTimeoutError, timings: any, request: Request);

                                                                    property event

                                                                    readonly event: string;

                                                                      property request

                                                                      readonly request: Request;

                                                                        property timings

                                                                        readonly timings: any;

                                                                          class UnsupportedProtocolError

                                                                          class UnsupportedProtocolError extends RequestError {}
                                                                          • An error to be thrown when given an unsupported protocol.

                                                                          constructor

                                                                          constructor(options: NormalizedOptions);

                                                                            class UploadError

                                                                            class UploadError extends RequestError {}
                                                                            • An error to be thrown when the request body is a stream and an error occurs while reading from that stream.

                                                                            constructor

                                                                            constructor(error: any, request: Request);

                                                                              property request

                                                                              readonly request: Request;

                                                                                Interfaces

                                                                                interface Agents

                                                                                interface Agents {}

                                                                                  property http

                                                                                  http?: http.Agent;

                                                                                    property http2

                                                                                    http2?: unknown;

                                                                                      property https

                                                                                      https?: https.Agent;

                                                                                        interface CacheOptions

                                                                                        interface CacheOptions {}

                                                                                          property cacheHeuristic

                                                                                          cacheHeuristic?: number;

                                                                                            property ignoreCargoCult

                                                                                            ignoreCargoCult?: boolean;

                                                                                              property immutableMinTimeToLive

                                                                                              immutableMinTimeToLive?: number;

                                                                                                property shared

                                                                                                shared?: boolean;

                                                                                                  interface CancelableRequest

                                                                                                  interface CancelableRequest<T extends Response | Response['body'] = Response['body']>
                                                                                                  extends PCancelable<T>,
                                                                                                  RequestEvents<CancelableRequest<T>> {}

                                                                                                    property buffer

                                                                                                    buffer: () => CancelableRequest<Buffer>;

                                                                                                      property json

                                                                                                      json: <ReturnType>() => CancelableRequest<ReturnType>;

                                                                                                        property text

                                                                                                        text: () => CancelableRequest<string>;

                                                                                                          interface Defaults

                                                                                                          interface Defaults extends PromiseOnly.Defaults, PlainDefaults {}

                                                                                                            interface ExtendOptions

                                                                                                            interface ExtendOptions extends Options {}
                                                                                                            • The options available for got.extend().

                                                                                                            property handlers

                                                                                                            handlers?: HandlerFunction[];
                                                                                                            • An 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 or asStream, depending on the options.isStream property.

                                                                                                              []

                                                                                                            property mutableDefaults

                                                                                                            mutableDefaults?: boolean;
                                                                                                            • A read-only boolean describing whether the defaults are mutable or not. If set to true, you can update headers over time, for example, update an access token when it expires.

                                                                                                              false

                                                                                                            interface Got

                                                                                                            interface Got extends Record<HTTPAlias, GotRequestFunction>, GotRequestFunction {}
                                                                                                            • An instance of got.

                                                                                                            property CacheError

                                                                                                            CacheError: typeof CacheError;
                                                                                                            • An error to be thrown when a cache method fails. For example, if the database goes down or there's a filesystem error.

                                                                                                            property CancelError

                                                                                                            CancelError: typeof CancelError;
                                                                                                            • An error to be thrown when the request is aborted with .cancel().

                                                                                                            property defaults

                                                                                                            defaults: InstanceDefaults;
                                                                                                            • The Got defaults used in that instance.

                                                                                                            property extend

                                                                                                            extend: (...instancesOrOptions: Array<Got | ExtendOptions>) => Got;
                                                                                                            • Configure a new got instance with default options. The options are merged with the parent instance's defaults.options using got.mergeOptions. You can access the resolved options with the .defaults property on the instance.

                                                                                                              Additionally, got.extend() accepts two properties from the defaults object: mutableDefaults and handlers.

                                                                                                              It is also possible to merges many instances into a single one: - options are merged using got.mergeOptions() (including hooks), - handlers are stored in an array (you can access them through instance.defaults.handlers).

                                                                                                              Example 1

                                                                                                              ```js const client = got.extend({ prefixUrl: 'https://example.com', headers: { 'x-unicorn': 'rainbow' } });

                                                                                                              client.get('demo');

                                                                                                              // HTTP Request => // GET /demo HTTP/1.1 // Host: example.com // x-unicorn: rainbow ```

                                                                                                            property HTTPError

                                                                                                            HTTPError: typeof HTTPError;
                                                                                                            • An error to be thrown when the server response code is not 2xx nor 3xx if options.followRedirect is true, but always except for 304. Includes a response property.

                                                                                                            property MaxRedirectsError

                                                                                                            MaxRedirectsError: typeof MaxRedirectsError;
                                                                                                            • An error to be thrown when the server redirects you more than ten times. Includes a response property.

                                                                                                            property mergeInstances

                                                                                                            mergeInstances: (parent: Got, ...instances: Got[]) => Got;
                                                                                                            • Merges multiple got instances into the parent.

                                                                                                            property mergeOptions

                                                                                                            mergeOptions: (...sources: Options[]) => NormalizedOptions;
                                                                                                            • Extends 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.

                                                                                                              Options are deeply merged to a new object. The value of each key is determined as follows:

                                                                                                              - If the new property is not defined, the old value is used. - If the new property is explicitly set to undefined: - If the parent property is a plain object, the parent value is deeply cloned. - Otherwise, undefined is used. - If the parent value is an instance of URLSearchParams: - 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. - Otherwise, the only available value is undefined. - If the new property is a plain object: - If the parent property is a plain object too, both values are merged recursively into a new object. - Otherwise, only the new value is deeply cloned. - If the new property is an Array, it overwrites the old one with a deep clone of the new property. - Properties that are not enumerable, such as context, body, json, and form, will not be merged. - Otherwise, the new value is assigned to the key.

                                                                                                              *Note:** Only Got options are merged! Custom user options should be defined via [options.context](#context).

                                                                                                              Example 1

                                                                                                              ``` const a = {headers: {cat: 'meow', wolf: ['bark', 'wrrr']}}; const b = {headers: {cow: 'moo', wolf: ['auuu']}};

                                                                                                              {...a, ...b} // => {headers: {cow: 'moo', wolf: ['auuu']}} got.mergeOptions(a, b) // => {headers: {cat: 'meow', cow: 'moo', wolf: ['auuu']}} ```

                                                                                                            property paginate

                                                                                                            paginate: GotPaginate;
                                                                                                            • Returns an async iterator.

                                                                                                              See pagination.options for more pagination options.

                                                                                                              Example 1

                                                                                                              ``` (async () => { const countLimit = 10;

                                                                                                              const pagination = got.paginate('https://api.github.com/repos/sindresorhus/got/commits', { pagination: {countLimit} });

                                                                                                              console.log(Printing latest ${countLimit} Got commits (newest to oldest):);

                                                                                                              for await (const commitData of pagination) { console.log(commitData.commit.message); } })(); ```

                                                                                                            property ParseError

                                                                                                            ParseError: typeof ParseError;
                                                                                                            • An error to be thrown when server response code is 2xx, and parsing body fails. Includes a response property.

                                                                                                            property ReadError

                                                                                                            ReadError: typeof ReadError;
                                                                                                            • An error to be thrown when reading from response stream fails.

                                                                                                            property RequestError

                                                                                                            RequestError: typeof RequestError;
                                                                                                            • An error to be thrown when a request fails. Contains a code property with error class code, like ECONNREFUSED.

                                                                                                            property stream

                                                                                                            stream: GotStream;
                                                                                                            • Sets options.isStream to true.

                                                                                                              Returns a [duplex stream](https://nodejs.org/api/stream.html#stream_class_stream_duplex) with additional events: - request - response - redirect - uploadProgress - downloadProgress - error

                                                                                                            property TimeoutError

                                                                                                            TimeoutError: typeof TimeoutError;
                                                                                                            • An error to be thrown when the request is aborted due to a timeout. Includes an event and timings property.

                                                                                                            property UnsupportedProtocolError

                                                                                                            UnsupportedProtocolError: typeof UnsupportedProtocolError;
                                                                                                            • An error to be thrown when given an unsupported protocol.

                                                                                                            property UploadError

                                                                                                            UploadError: typeof UploadError;
                                                                                                            • An error to be thrown when the request body is a stream and an error occurs while reading from that stream.

                                                                                                            interface GotPaginate

                                                                                                            interface GotPaginate {}
                                                                                                            • An instance of got.paginate.

                                                                                                            property all

                                                                                                            all: (<T, R = unknown>(
                                                                                                            url: string | URL,
                                                                                                            options?: OptionsWithPagination<T, R>
                                                                                                            ) => Promise<T[]>) &
                                                                                                            (<T, R = unknown>(options?: OptionsWithPagination<T, R>) => Promise<T[]>);
                                                                                                            • Returns a Promise for an array of all results.

                                                                                                              See pagination.options for more pagination options.

                                                                                                              Example 1

                                                                                                              ``` (async () => { const countLimit = 10;

                                                                                                              const results = await got.paginate.all('https://api.github.com/repos/sindresorhus/got/commits', { pagination: {countLimit} });

                                                                                                              console.log(Printing latest ${countLimit} Got commits (newest to oldest):); console.log(results); })(); ```

                                                                                                            property each

                                                                                                            each: (<T, R = unknown>(
                                                                                                            url: string | URL,
                                                                                                            options?: OptionsWithPagination<T, R>
                                                                                                            ) => AsyncIterableIterator<T>) &
                                                                                                            (<T, R = unknown>(
                                                                                                            options?: OptionsWithPagination<T, R>
                                                                                                            ) => AsyncIterableIterator<T>);
                                                                                                            • Returns an async iterator.

                                                                                                              See pagination.options for more pagination options.

                                                                                                              Example 1

                                                                                                              ``` (async () => { const countLimit = 10;

                                                                                                              const pagination = got.paginate('https://api.github.com/repos/sindresorhus/got/commits', { pagination: {countLimit} });

                                                                                                              console.log(Printing latest ${countLimit} Got commits (newest to oldest):);

                                                                                                              for await (const commitData of pagination) { console.log(commitData.commit.message); } })(); ```

                                                                                                            call signature

                                                                                                            <T, R = unknown>(
                                                                                                            url: string | URL,
                                                                                                            options?: OptionsWithPagination<T, R>
                                                                                                            ): AsyncIterableIterator<T>;
                                                                                                            • Same as GotPaginate.each.

                                                                                                            call signature

                                                                                                            <T, R = unknown>(
                                                                                                            options?: OptionsWithPagination<T, R>
                                                                                                            ): AsyncIterableIterator<T>;
                                                                                                            • Same as GotPaginate.each.

                                                                                                            interface GotRequestFunction

                                                                                                            interface GotRequestFunction {}

                                                                                                              call signature

                                                                                                              (url: string | URL, options?: OptionsOfTextResponseBody): CancelableRequest<
                                                                                                              Response<string>
                                                                                                              >;

                                                                                                                call signature

                                                                                                                <T>(url: string | URL, options?: OptionsOfJSONResponseBody): CancelableRequest<
                                                                                                                Response<T>
                                                                                                                >;

                                                                                                                  call signature

                                                                                                                  (
                                                                                                                  url: string | URL,
                                                                                                                  options?: Merge<OptionsOfBufferResponseBody, ResponseBodyOnly>
                                                                                                                  ): CancelableRequest<Buffer>;

                                                                                                                    call signature

                                                                                                                    (
                                                                                                                    options: Merge<OptionsOfTextResponseBody, ResponseBodyOnly>
                                                                                                                    ): CancelableRequest<string>;

                                                                                                                      call signature

                                                                                                                      <T>(
                                                                                                                      options: Merge<OptionsOfJSONResponseBody, ResponseBodyOnly>
                                                                                                                      ): CancelableRequest<T>;

                                                                                                                        call signature

                                                                                                                        (
                                                                                                                        options: Merge<OptionsOfBufferResponseBody, ResponseBodyOnly>
                                                                                                                        ): CancelableRequest<Buffer>;

                                                                                                                          call signature

                                                                                                                          (
                                                                                                                          url: string | URL,
                                                                                                                          options?: Merge<
                                                                                                                          Options,
                                                                                                                          {
                                                                                                                          isStream: true;
                                                                                                                          }
                                                                                                                          >
                                                                                                                          ): Request;

                                                                                                                            call signature

                                                                                                                            (
                                                                                                                            options: Merge<
                                                                                                                            Options,
                                                                                                                            {
                                                                                                                            isStream: true;
                                                                                                                            }
                                                                                                                            >
                                                                                                                            ): Request;

                                                                                                                              call signature

                                                                                                                              (url: string | URL, options?: Options): CancelableRequest | Request;

                                                                                                                                call signature

                                                                                                                                (options: Options): CancelableRequest | Request;

                                                                                                                                  call signature

                                                                                                                                  (url: string | URL, options?: OptionsOfBufferResponseBody): CancelableRequest<
                                                                                                                                  Response<Buffer>
                                                                                                                                  >;

                                                                                                                                    call signature

                                                                                                                                    (
                                                                                                                                    url: string | URL,
                                                                                                                                    options?: OptionsOfUnknownResponseBody
                                                                                                                                    ): CancelableRequest<Response>;

                                                                                                                                      call signature

                                                                                                                                      (options: OptionsOfTextResponseBody): CancelableRequest<Response<string>>;

                                                                                                                                        call signature

                                                                                                                                        <T>(options: OptionsOfJSONResponseBody): CancelableRequest<Response<T>>;

                                                                                                                                          call signature

                                                                                                                                          (options: OptionsOfBufferResponseBody): CancelableRequest<Response<Buffer>>;

                                                                                                                                            call signature

                                                                                                                                            (options: OptionsOfUnknownResponseBody): CancelableRequest<Response>;

                                                                                                                                              call signature

                                                                                                                                              (
                                                                                                                                              url: string | URL,
                                                                                                                                              options?: Merge<OptionsOfTextResponseBody, ResponseBodyOnly>
                                                                                                                                              ): CancelableRequest<string>;

                                                                                                                                                call signature

                                                                                                                                                <T>(
                                                                                                                                                url: string | URL,
                                                                                                                                                options?: Merge<OptionsOfJSONResponseBody, ResponseBodyOnly>
                                                                                                                                                ): CancelableRequest<T>;

                                                                                                                                                  interface Hooks

                                                                                                                                                  interface Hooks extends PromiseOnly.Hooks, PlainHooks {}
                                                                                                                                                  • All available hook of Got.

                                                                                                                                                  interface HTTPSOptions

                                                                                                                                                  interface HTTPSOptions {}

                                                                                                                                                    property certificate

                                                                                                                                                    certificate?: SecureContextOptions['cert'];
                                                                                                                                                    • [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.

                                                                                                                                                      One cert chain should be provided per private key (options.https.key).

                                                                                                                                                      When providing multiple cert chains, they do not have to be in the same order as their private keys in options.https.key.

                                                                                                                                                      If the intermediate certificates are not provided, the peer will not be able to validate the certificate, and the handshake will fail.

                                                                                                                                                    property certificateAuthority

                                                                                                                                                    certificateAuthority?: SecureContextOptions['ca'];
                                                                                                                                                    • Override the default Certificate Authorities ([from Mozilla](https://ccadb-public.secure.force.com/mozilla/IncludedCACertificateReport)).

                                                                                                                                                      Example 1

                                                                                                                                                      ``` // Single Certificate Authority got('https://example.com', { https: { certificateAuthority: fs.readFileSync('./my_ca.pem') } }); ```

                                                                                                                                                    property checkServerIdentity

                                                                                                                                                    checkServerIdentity?: CheckServerIdentityFunction;

                                                                                                                                                      property key

                                                                                                                                                      key?: SecureContextOptions['key'];
                                                                                                                                                      • Private keys in [PEM](https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail) format.

                                                                                                                                                        [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.

                                                                                                                                                        Multiple keys with different passphrases can be provided as an array of {pem: <string | Buffer>, passphrase: <string>}

                                                                                                                                                      property passphrase

                                                                                                                                                      passphrase?: SecureContextOptions['passphrase'];
                                                                                                                                                      • The passphrase to decrypt the options.https.key (if different keys have different passphrases refer to options.https.key documentation).

                                                                                                                                                      property pfx

                                                                                                                                                      pfx?: SecureContextOptions['pfx'];

                                                                                                                                                        property rejectUnauthorized

                                                                                                                                                        rejectUnauthorized?: https.RequestOptions['rejectUnauthorized'];

                                                                                                                                                          interface InstanceDefaults

                                                                                                                                                          interface InstanceDefaults {}
                                                                                                                                                          • Defaults for each Got instance.

                                                                                                                                                          property handlers

                                                                                                                                                          handlers: HandlerFunction[];
                                                                                                                                                          • An 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 or asStream, depending on the options.isStream property.

                                                                                                                                                            []

                                                                                                                                                          property mutableDefaults

                                                                                                                                                          mutableDefaults: boolean;
                                                                                                                                                          • A read-only boolean describing whether the defaults are mutable or not. If set to true, you can update headers over time, for example, update an access token when it expires.

                                                                                                                                                            false

                                                                                                                                                          property options

                                                                                                                                                          options: DefaultOptions;
                                                                                                                                                          • An object containing the default options of Got.

                                                                                                                                                          interface NormalizedOptions

                                                                                                                                                          interface NormalizedOptions
                                                                                                                                                          extends PromiseOnly.NormalizedOptions,
                                                                                                                                                          NormalizedPlainOptions {}

                                                                                                                                                            interface Options

                                                                                                                                                            interface Options extends PromiseOnly.Options, PlainOptions {}

                                                                                                                                                              interface PaginationOptions

                                                                                                                                                              interface PaginationOptions<T, R> {}

                                                                                                                                                                property pagination

                                                                                                                                                                pagination?: {
                                                                                                                                                                /**
                                                                                                                                                                A function that transform [`Response`](#response) into an array of items.
                                                                                                                                                                This is where you should do the parsing.
                                                                                                                                                                @default response => JSON.parse(response.body)
                                                                                                                                                                */
                                                                                                                                                                transform?: (response: Response<R>) => Promise<T[]> | T[];
                                                                                                                                                                /**
                                                                                                                                                                Checks whether the item should be emitted or not.
                                                                                                                                                                @default (item, allItems, currentItems) => true
                                                                                                                                                                */
                                                                                                                                                                filter?: (item: T, allItems: T[], currentItems: T[]) => boolean;
                                                                                                                                                                /**
                                                                                                                                                                The function takes three arguments:
                                                                                                                                                                - `response` - The current response object.
                                                                                                                                                                - `allItems` - An array of the emitted items.
                                                                                                                                                                - `currentItems` - Items from the current response.
                                                                                                                                                                It 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.
                                                                                                                                                                @example
                                                                                                                                                                ```
                                                                                                                                                                const got = require('got');
                                                                                                                                                                (async () => {
                                                                                                                                                                const limit = 10;
                                                                                                                                                                const items = got.paginate('https://example.com/items', {
                                                                                                                                                                searchParams: {
                                                                                                                                                                limit,
                                                                                                                                                                offset: 0
                                                                                                                                                                },
                                                                                                                                                                pagination: {
                                                                                                                                                                paginate: (response, allItems, currentItems) => {
                                                                                                                                                                const previousSearchParams = response.request.options.searchParams;
                                                                                                                                                                const previousOffset = previousSearchParams.get('offset');
                                                                                                                                                                if (currentItems.length < limit) {
                                                                                                                                                                return false;
                                                                                                                                                                }
                                                                                                                                                                return {
                                                                                                                                                                searchParams: {
                                                                                                                                                                ...previousSearchParams,
                                                                                                                                                                offset: Number(previousOffset) + limit,
                                                                                                                                                                }
                                                                                                                                                                };
                                                                                                                                                                }
                                                                                                                                                                }
                                                                                                                                                                });
                                                                                                                                                                console.log('Items from all pages:', items);
                                                                                                                                                                })();
                                                                                                                                                                ```
                                                                                                                                                                */
                                                                                                                                                                paginate?: (
                                                                                                                                                                response: Response<R>,
                                                                                                                                                                allItems: T[],
                                                                                                                                                                currentItems: T[]
                                                                                                                                                                ) => Options | false;
                                                                                                                                                                /**
                                                                                                                                                                Checks whether the pagination should continue.
                                                                                                                                                                For 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.
                                                                                                                                                                @default (item, allItems, currentItems) => true
                                                                                                                                                                */
                                                                                                                                                                shouldContinue?: (item: T, allItems: T[], currentItems: T[]) => boolean;
                                                                                                                                                                /**
                                                                                                                                                                The maximum amount of items that should be emitted.
                                                                                                                                                                @default Infinity
                                                                                                                                                                */
                                                                                                                                                                countLimit?: number;
                                                                                                                                                                /**
                                                                                                                                                                Milliseconds to wait before the next request is triggered.
                                                                                                                                                                @default 0
                                                                                                                                                                */
                                                                                                                                                                backoff?: number;
                                                                                                                                                                /**
                                                                                                                                                                The maximum amount of request that should be triggered.
                                                                                                                                                                Retries on failure are not counted towards this limit.
                                                                                                                                                                For example, it can be helpful during development to avoid an infinite number of requests.
                                                                                                                                                                @default 10000
                                                                                                                                                                */
                                                                                                                                                                requestLimit?: number;
                                                                                                                                                                /**
                                                                                                                                                                Defines how the parameter `allItems` in pagination.paginate, pagination.filter and pagination.shouldContinue is managed.
                                                                                                                                                                When set to `false`, the parameter `allItems` is always an empty array.
                                                                                                                                                                This option can be helpful to save on memory usage when working with a large dataset.
                                                                                                                                                                */
                                                                                                                                                                stackAllItems?: boolean;
                                                                                                                                                                };
                                                                                                                                                                • All options accepted by got.paginate().

                                                                                                                                                                interface PlainResponse

                                                                                                                                                                interface PlainResponse extends IncomingMessageWithTimings {}

                                                                                                                                                                  property body

                                                                                                                                                                  body?: unknown;
                                                                                                                                                                  • The result of the request.

                                                                                                                                                                  property ip

                                                                                                                                                                  ip?: string;
                                                                                                                                                                  • The remote IP address.

                                                                                                                                                                    This is hopefully a temporary limitation, see [lukechilds/cacheable-request#86](https://github.com/lukechilds/cacheable-request/issues/86).

                                                                                                                                                                    __Note__: Not available when the response is cached.

                                                                                                                                                                  property isFromCache

                                                                                                                                                                  isFromCache: boolean;
                                                                                                                                                                  • Whether the response was retrieved from the cache.

                                                                                                                                                                  property rawBody

                                                                                                                                                                  rawBody?: Buffer;
                                                                                                                                                                  • The raw result of the request.

                                                                                                                                                                  property redirectUrls

                                                                                                                                                                  redirectUrls: string[];
                                                                                                                                                                  • The redirect URLs.

                                                                                                                                                                  property request

                                                                                                                                                                  request: Request;
                                                                                                                                                                  • - options - The Got options that were set on this request.

                                                                                                                                                                    __Note__: This is not a [http.ClientRequest](https://nodejs.org/api/http.html#http_class_http_clientrequest).

                                                                                                                                                                  property requestUrl

                                                                                                                                                                  requestUrl: string;
                                                                                                                                                                  • The original request URL.

                                                                                                                                                                  property retryCount

                                                                                                                                                                  retryCount: number;
                                                                                                                                                                  • The number of times the request was retried.

                                                                                                                                                                  property statusCode

                                                                                                                                                                  statusCode: number;
                                                                                                                                                                  • The status code of the response.

                                                                                                                                                                  property timings

                                                                                                                                                                  timings: Timings;
                                                                                                                                                                  • The object contains the following properties:

                                                                                                                                                                    - start - Time when the request started. - socket - Time when a socket was assigned to the request. - lookup - Time when the DNS lookup finished. - connect - Time when the socket successfully connected. - secureConnect - Time when the socket securely connected. - upload - Time when the request finished uploading. - response - Time when the request fired response event. - end - Time when the response fired end event. - error - Time when the request fired error event. - abort - Time when the request fired abort event. - phases - wait - timings.socket - timings.start - dns - timings.lookup - timings.socket - tcp - timings.connect - timings.lookup - tls - timings.secureConnect - timings.connect - request - timings.upload - (timings.secureConnect || timings.connect) - firstByte - timings.response - timings.upload - download - timings.end - timings.response - total - (timings.end || timings.error || timings.abort) - timings.start

                                                                                                                                                                    If something has not been measured yet, it will be undefined.

                                                                                                                                                                    __Note__: The time is a number representing the milliseconds elapsed since the UNIX epoch.

                                                                                                                                                                  property url

                                                                                                                                                                  url: string;
                                                                                                                                                                  • The request URL or the final URL after redirects.

                                                                                                                                                                  interface Progress

                                                                                                                                                                  interface Progress {}

                                                                                                                                                                    property percent

                                                                                                                                                                    percent: number;

                                                                                                                                                                      property total

                                                                                                                                                                      total?: number;

                                                                                                                                                                        property transferred

                                                                                                                                                                        transferred: number;

                                                                                                                                                                          interface PromiseCookieJar

                                                                                                                                                                          interface PromiseCookieJar {}

                                                                                                                                                                            property getCookieString

                                                                                                                                                                            getCookieString: (url: string) => Promise<string>;

                                                                                                                                                                              property setCookie

                                                                                                                                                                              setCookie: (rawCookie: string, url: string) => Promise<unknown>;

                                                                                                                                                                                interface RequestEvents

                                                                                                                                                                                interface RequestEvents<T> {}

                                                                                                                                                                                  property on

                                                                                                                                                                                  on: ((name: 'request', listener: (request: http.ClientRequest) => void) => T) &
                                                                                                                                                                                  /**
                                                                                                                                                                                  The `response` event to get the response object of the final request.
                                                                                                                                                                                  */
                                                                                                                                                                                  (<R extends Response>(
                                                                                                                                                                                  name: 'response',
                                                                                                                                                                                  listener: (response: R) => void
                                                                                                                                                                                  ) => T) &
                                                                                                                                                                                  /**
                                                                                                                                                                                  The `redirect` event to get the response object of a redirect. The second argument is options for the next request to the redirect location.
                                                                                                                                                                                  */
                                                                                                                                                                                  (<R extends Response, N extends NormalizedOptions>(
                                                                                                                                                                                  name: 'redirect',
                                                                                                                                                                                  listener: (response: R, nextOptions: N) => void
                                                                                                                                                                                  ) => T) &
                                                                                                                                                                                  /**
                                                                                                                                                                                  Progress events for uploading (sending a request) and downloading (receiving a response).
                                                                                                                                                                                  The `progress` argument is an object like:
                                                                                                                                                                                  ```js
                                                                                                                                                                                  {
                                                                                                                                                                                  percent: 0.1,
                                                                                                                                                                                  transferred: 1024,
                                                                                                                                                                                  total: 10240
                                                                                                                                                                                  }
                                                                                                                                                                                  ```
                                                                                                                                                                                  If the `content-length` header is missing, `total` will be `undefined`.
                                                                                                                                                                                  @example
                                                                                                                                                                                  ```js
                                                                                                                                                                                  (async () => {
                                                                                                                                                                                  const response = await got('https://sindresorhus.com')
                                                                                                                                                                                  .on('downloadProgress', progress => {
                                                                                                                                                                                  // Report download progress
                                                                                                                                                                                  })
                                                                                                                                                                                  .on('uploadProgress', progress => {
                                                                                                                                                                                  // Report upload progress
                                                                                                                                                                                  });
                                                                                                                                                                                  console.log(response);
                                                                                                                                                                                  })();
                                                                                                                                                                                  ```
                                                                                                                                                                                  */
                                                                                                                                                                                  ((
                                                                                                                                                                                  name: 'uploadProgress' | 'downloadProgress',
                                                                                                                                                                                  listener: (progress: Progress) => void
                                                                                                                                                                                  ) => T) &
                                                                                                                                                                                  /**
                                                                                                                                                                                  To enable retrying on a Got stream, it is required to have a `retry` handler attached.
                                                                                                                                                                                  When this event is emitted, you should reset the stream you were writing to and prepare the body again.
                                                                                                                                                                                  See `got.options.retry` for more information.
                                                                                                                                                                                  */
                                                                                                                                                                                  ((
                                                                                                                                                                                  name: 'retry',
                                                                                                                                                                                  listener: (retryCount: number, error: RequestError) => void
                                                                                                                                                                                  ) => T);
                                                                                                                                                                                  • request event to get the request object of the request.

                                                                                                                                                                                    __Tip__: You can use request event to abort requests.

                                                                                                                                                                                    Example 1

                                                                                                                                                                                    ``` got.stream('https://github.com') .on('request', request => setTimeout(() => request.destroy(), 50)); ```

                                                                                                                                                                                  interface RequiredRetryOptions

                                                                                                                                                                                  interface RequiredRetryOptions {}
                                                                                                                                                                                  • An 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.

                                                                                                                                                                                    Delays between retries counts with function 1000 * Math.pow(2, retry) + Math.random() * 100, where retry is attempt number (starts from 1).

                                                                                                                                                                                    The 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).

                                                                                                                                                                                    By default, it retries *only* on the specified methods, status codes, and on these network errors: - ETIMEDOUT: One of the [timeout](#timeout) limits were reached. - ECONNRESET: Connection was forcibly closed by a peer. - EADDRINUSE: Could not bind to any free port. - ECONNREFUSED: Connection was refused by the server. - EPIPE: The remote side of the stream being written has been closed. - ENOTFOUND: Couldn't resolve the hostname to an IP address. - ENETUNREACH: No internet connection. - EAI_AGAIN: DNS lookup timed out.

                                                                                                                                                                                    __Note__: If maxRetryAfter is set to undefined, it will use options.timeout. __Note__: If [Retry-After](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) header is greater than maxRetryAfter, it will cancel the request.

                                                                                                                                                                                  property calculateDelay

                                                                                                                                                                                  calculateDelay: RetryFunction;

                                                                                                                                                                                    property errorCodes

                                                                                                                                                                                    errorCodes: string[];

                                                                                                                                                                                      property limit

                                                                                                                                                                                      limit: number;

                                                                                                                                                                                        property maxRetryAfter

                                                                                                                                                                                        maxRetryAfter?: number;

                                                                                                                                                                                          property methods

                                                                                                                                                                                          methods: Method[];

                                                                                                                                                                                            property statusCodes

                                                                                                                                                                                            statusCodes: number[];

                                                                                                                                                                                              interface Response

                                                                                                                                                                                              interface Response<T = unknown> extends PlainResponse {}

                                                                                                                                                                                                property body

                                                                                                                                                                                                body: T;
                                                                                                                                                                                                • The result of the request.

                                                                                                                                                                                                property rawBody

                                                                                                                                                                                                rawBody: Buffer;
                                                                                                                                                                                                • The raw result of the request.

                                                                                                                                                                                                interface RetryObject

                                                                                                                                                                                                interface RetryObject {}

                                                                                                                                                                                                  property attemptCount

                                                                                                                                                                                                  attemptCount: number;

                                                                                                                                                                                                    property computedValue

                                                                                                                                                                                                    computedValue: number;

                                                                                                                                                                                                      property error

                                                                                                                                                                                                      error: TimeoutError | RequestError;

                                                                                                                                                                                                        property retryAfter

                                                                                                                                                                                                        retryAfter?: number;

                                                                                                                                                                                                          property retryOptions

                                                                                                                                                                                                          retryOptions: RequiredRetryOptions;

                                                                                                                                                                                                            interface ToughCookieJar

                                                                                                                                                                                                            interface ToughCookieJar {}

                                                                                                                                                                                                              property getCookieString

                                                                                                                                                                                                              getCookieString: ((
                                                                                                                                                                                                              currentUrl: string,
                                                                                                                                                                                                              options: Record<string, unknown>,
                                                                                                                                                                                                              cb: (err: Error | null, cookies: string) => void
                                                                                                                                                                                                              ) => void) &
                                                                                                                                                                                                              ((
                                                                                                                                                                                                              url: string,
                                                                                                                                                                                                              callback: (error: Error | null, cookieHeader: string) => void
                                                                                                                                                                                                              ) => void);

                                                                                                                                                                                                                property setCookie

                                                                                                                                                                                                                setCookie: ((
                                                                                                                                                                                                                cookieOrString: unknown,
                                                                                                                                                                                                                currentUrl: string,
                                                                                                                                                                                                                options: Record<string, unknown>,
                                                                                                                                                                                                                cb: (err: Error | null, cookie: unknown) => void
                                                                                                                                                                                                                ) => void) &
                                                                                                                                                                                                                ((
                                                                                                                                                                                                                rawCookie: string,
                                                                                                                                                                                                                url: string,
                                                                                                                                                                                                                callback: (error: Error | null, result: unknown) => void
                                                                                                                                                                                                                ) => void);

                                                                                                                                                                                                                  Type Aliases

                                                                                                                                                                                                                  type AfterResponseHook

                                                                                                                                                                                                                  type AfterResponseHook = (
                                                                                                                                                                                                                  response: Response,
                                                                                                                                                                                                                  retryWithMergedOptions: (options: Options) => CancelableRequest<Response>
                                                                                                                                                                                                                  ) =>
                                                                                                                                                                                                                  | Response
                                                                                                                                                                                                                  | CancelableRequest<Response>
                                                                                                                                                                                                                  | Promise<Response | CancelableRequest<Response>>;

                                                                                                                                                                                                                    type BeforeErrorHook

                                                                                                                                                                                                                    type BeforeErrorHook = (error: RequestError) => Promisable<RequestError>;

                                                                                                                                                                                                                      type BeforeRedirectHook

                                                                                                                                                                                                                      type BeforeRedirectHook = (
                                                                                                                                                                                                                      options: NormalizedOptions,
                                                                                                                                                                                                                      response: Response
                                                                                                                                                                                                                      ) => Promisable<void>;

                                                                                                                                                                                                                        type BeforeRequestHook

                                                                                                                                                                                                                        type BeforeRequestHook = (
                                                                                                                                                                                                                        options: NormalizedOptions
                                                                                                                                                                                                                        ) => Promisable<void | Response | ResponseLike>;

                                                                                                                                                                                                                          type BeforeRetryHook

                                                                                                                                                                                                                          type BeforeRetryHook = (
                                                                                                                                                                                                                          options: NormalizedOptions,
                                                                                                                                                                                                                          error?: RequestError,
                                                                                                                                                                                                                          retryCount?: number
                                                                                                                                                                                                                          ) => void | Promise<void>;

                                                                                                                                                                                                                            type GotReturn

                                                                                                                                                                                                                            type GotReturn = Request | CancelableRequest;
                                                                                                                                                                                                                            • A Request object returned by calling Got, or any of the Got HTTP alias request functions.

                                                                                                                                                                                                                            type GotStream

                                                                                                                                                                                                                            type GotStream = GotStreamFunction & Record<HTTPAlias, GotStreamFunction>;
                                                                                                                                                                                                                            • An instance of got.stream().

                                                                                                                                                                                                                            type HandlerFunction

                                                                                                                                                                                                                            type HandlerFunction = <T extends GotReturn>(
                                                                                                                                                                                                                            options: NormalizedOptions,
                                                                                                                                                                                                                            next: (options: NormalizedOptions) => T
                                                                                                                                                                                                                            ) => T | Promise<T>;
                                                                                                                                                                                                                            • A function to handle options and returns a Request object. It acts sort of like a "global hook", and will be called before any actual request is made.

                                                                                                                                                                                                                            type Headers

                                                                                                                                                                                                                            type Headers = Record<string, string | string[] | undefined>;

                                                                                                                                                                                                                              type HookEvent

                                                                                                                                                                                                                              type HookEvent = PromiseOnly.HookEvent | PlainHookEvent;
                                                                                                                                                                                                                              • All hook events acceptable by Got.

                                                                                                                                                                                                                              type HTTPAlias

                                                                                                                                                                                                                              type HTTPAlias = 'get' | 'post' | 'put' | 'patch' | 'head' | 'delete';
                                                                                                                                                                                                                              • All available HTTP request methods provided by Got.

                                                                                                                                                                                                                              type InitHook

                                                                                                                                                                                                                              type InitHook = (options: Options) => void;

                                                                                                                                                                                                                                type Method

                                                                                                                                                                                                                                type Method =
                                                                                                                                                                                                                                | 'GET'
                                                                                                                                                                                                                                | 'POST'
                                                                                                                                                                                                                                | 'PUT'
                                                                                                                                                                                                                                | 'PATCH'
                                                                                                                                                                                                                                | 'HEAD'
                                                                                                                                                                                                                                | 'DELETE'
                                                                                                                                                                                                                                | 'OPTIONS'
                                                                                                                                                                                                                                | 'TRACE'
                                                                                                                                                                                                                                | 'get'
                                                                                                                                                                                                                                | 'post'
                                                                                                                                                                                                                                | 'put'
                                                                                                                                                                                                                                | 'patch'
                                                                                                                                                                                                                                | 'head'
                                                                                                                                                                                                                                | 'delete'
                                                                                                                                                                                                                                | 'options'
                                                                                                                                                                                                                                | 'trace';
                                                                                                                                                                                                                                • All available HTTP request methods provided by Got.

                                                                                                                                                                                                                                type OptionsOfBufferResponseBody

                                                                                                                                                                                                                                type OptionsOfBufferResponseBody = Merge<
                                                                                                                                                                                                                                Options,
                                                                                                                                                                                                                                {
                                                                                                                                                                                                                                isStream?: false;
                                                                                                                                                                                                                                resolveBodyOnly?: false;
                                                                                                                                                                                                                                responseType: 'buffer';
                                                                                                                                                                                                                                }
                                                                                                                                                                                                                                >;

                                                                                                                                                                                                                                  type OptionsOfJSONResponseBody

                                                                                                                                                                                                                                  type OptionsOfJSONResponseBody = Merge<
                                                                                                                                                                                                                                  Options,
                                                                                                                                                                                                                                  {
                                                                                                                                                                                                                                  isStream?: false;
                                                                                                                                                                                                                                  resolveBodyOnly?: false;
                                                                                                                                                                                                                                  responseType?: 'json';
                                                                                                                                                                                                                                  }
                                                                                                                                                                                                                                  >;

                                                                                                                                                                                                                                    type OptionsOfTextResponseBody

                                                                                                                                                                                                                                    type OptionsOfTextResponseBody = Merge<
                                                                                                                                                                                                                                    Options,
                                                                                                                                                                                                                                    {
                                                                                                                                                                                                                                    isStream?: false;
                                                                                                                                                                                                                                    resolveBodyOnly?: false;
                                                                                                                                                                                                                                    responseType?: 'text';
                                                                                                                                                                                                                                    }
                                                                                                                                                                                                                                    >;

                                                                                                                                                                                                                                      type OptionsOfUnknownResponseBody

                                                                                                                                                                                                                                      type OptionsOfUnknownResponseBody = Merge<
                                                                                                                                                                                                                                      Options,
                                                                                                                                                                                                                                      {
                                                                                                                                                                                                                                      isStream?: false;
                                                                                                                                                                                                                                      resolveBodyOnly?: false;
                                                                                                                                                                                                                                      }
                                                                                                                                                                                                                                      >;

                                                                                                                                                                                                                                        type OptionsWithPagination

                                                                                                                                                                                                                                        type OptionsWithPagination<T = unknown, R = unknown> = Merge<
                                                                                                                                                                                                                                        Options,
                                                                                                                                                                                                                                        PaginationOptions<T, R>
                                                                                                                                                                                                                                        >;

                                                                                                                                                                                                                                          type ParseJsonFunction

                                                                                                                                                                                                                                          type ParseJsonFunction = (text: string) => unknown;

                                                                                                                                                                                                                                            type RequestFunction

                                                                                                                                                                                                                                            type RequestFunction = (
                                                                                                                                                                                                                                            url: URL,
                                                                                                                                                                                                                                            options: RequestOptions,
                                                                                                                                                                                                                                            callback?: (response: AcceptableResponse) => void
                                                                                                                                                                                                                                            ) => AcceptableRequestResult;

                                                                                                                                                                                                                                              type ResponseType

                                                                                                                                                                                                                                              type ResponseType = 'json' | 'buffer' | 'text';
                                                                                                                                                                                                                                              • All parsing methods supported by Got.

                                                                                                                                                                                                                                              type RetryFunction

                                                                                                                                                                                                                                              type RetryFunction = (retryObject: RetryObject) => number | Promise<number>;

                                                                                                                                                                                                                                                type StreamOptions

                                                                                                                                                                                                                                                type StreamOptions = Merge<
                                                                                                                                                                                                                                                Options,
                                                                                                                                                                                                                                                {
                                                                                                                                                                                                                                                isStream?: true;
                                                                                                                                                                                                                                                }
                                                                                                                                                                                                                                                >;

                                                                                                                                                                                                                                                  type StrictOptions

                                                                                                                                                                                                                                                  type StrictOptions = Except<
                                                                                                                                                                                                                                                  Options,
                                                                                                                                                                                                                                                  'isStream' | 'responseType' | 'resolveBodyOnly'
                                                                                                                                                                                                                                                  >;

                                                                                                                                                                                                                                                    type StringifyJsonFunction

                                                                                                                                                                                                                                                    type StringifyJsonFunction = (object: unknown) => string;

                                                                                                                                                                                                                                                      Namespaces

                                                                                                                                                                                                                                                      namespace PromiseOnly

                                                                                                                                                                                                                                                      namespace PromiseOnly {}

                                                                                                                                                                                                                                                        interface Defaults

                                                                                                                                                                                                                                                        interface Defaults {}

                                                                                                                                                                                                                                                          property isStream

                                                                                                                                                                                                                                                          isStream: boolean;

                                                                                                                                                                                                                                                            property pagination

                                                                                                                                                                                                                                                            pagination?: Required<PaginationOptions<unknown, unknown>['pagination']>;

                                                                                                                                                                                                                                                              property resolveBodyOnly

                                                                                                                                                                                                                                                              resolveBodyOnly: boolean;

                                                                                                                                                                                                                                                                property responseType

                                                                                                                                                                                                                                                                responseType: ResponseType;

                                                                                                                                                                                                                                                                  interface Hooks

                                                                                                                                                                                                                                                                  interface Hooks {}

                                                                                                                                                                                                                                                                    property afterResponse

                                                                                                                                                                                                                                                                    afterResponse?: AfterResponseHook[];
                                                                                                                                                                                                                                                                    • Called with [response object](#response) and a retry function. Calling the retry function will trigger beforeRetry hooks.

                                                                                                                                                                                                                                                                      Each function should return the response. This is especially useful when you want to refresh an access token.

                                                                                                                                                                                                                                                                      __Note__: When using streams, this hook is ignored.

                                                                                                                                                                                                                                                                      Example 1

                                                                                                                                                                                                                                                                      ``` const got = require('got');

                                                                                                                                                                                                                                                                      const instance = got.extend({ hooks: { afterResponse: [ (response, retryWithMergedOptions) => { if (response.statusCode === 401) { // Unauthorized const updatedOptions = { headers: { token: getNewToken() // Refresh the access token } };

                                                                                                                                                                                                                                                                      // Save for further requests instance.defaults.options = got.mergeOptions(instance.defaults.options, updatedOptions);

                                                                                                                                                                                                                                                                      // Make a new retry return retryWithMergedOptions(updatedOptions); }

                                                                                                                                                                                                                                                                      // No changes otherwise return response; } ], beforeRetry: [ (options, error, retryCount) => { // This will be called on retryWithMergedOptions(...) } ] }, mutableDefaults: true }); ```

                                                                                                                                                                                                                                                                    interface NormalizedOptions

                                                                                                                                                                                                                                                                    interface NormalizedOptions {}

                                                                                                                                                                                                                                                                      property encoding

                                                                                                                                                                                                                                                                      encoding?: BufferEncoding;

                                                                                                                                                                                                                                                                        property isStream

                                                                                                                                                                                                                                                                        isStream: boolean;

                                                                                                                                                                                                                                                                          property pagination

                                                                                                                                                                                                                                                                          pagination?: Required<PaginationOptions<unknown, unknown>['pagination']>;

                                                                                                                                                                                                                                                                            property resolveBodyOnly

                                                                                                                                                                                                                                                                            resolveBodyOnly: boolean;

                                                                                                                                                                                                                                                                              property responseType

                                                                                                                                                                                                                                                                              responseType: ResponseType;

                                                                                                                                                                                                                                                                                interface Options

                                                                                                                                                                                                                                                                                interface Options extends PaginationOptions<unknown, unknown> {}

                                                                                                                                                                                                                                                                                  property encoding

                                                                                                                                                                                                                                                                                  encoding?: BufferEncoding;
                                                                                                                                                                                                                                                                                  • [Encoding](https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings) to be used on setEncoding of the response data.

                                                                                                                                                                                                                                                                                    To get a [Buffer](https://nodejs.org/api/buffer.html), you need to set responseType to buffer instead. Don't set this option to null.

                                                                                                                                                                                                                                                                                    __Note__: This doesn't affect streams! Instead, you need to do got.stream(...).setEncoding(encoding).

                                                                                                                                                                                                                                                                                    'utf-8'

                                                                                                                                                                                                                                                                                  property isStream

                                                                                                                                                                                                                                                                                  isStream?: boolean;
                                                                                                                                                                                                                                                                                  • Returns a Stream instead of a Promise. This is equivalent to calling got.stream(url, options?).

                                                                                                                                                                                                                                                                                    false

                                                                                                                                                                                                                                                                                  property resolveBodyOnly

                                                                                                                                                                                                                                                                                  resolveBodyOnly?: boolean;
                                                                                                                                                                                                                                                                                  • When set to true the promise will return the Response body instead of the Response object.

                                                                                                                                                                                                                                                                                    false

                                                                                                                                                                                                                                                                                  property responseType

                                                                                                                                                                                                                                                                                  responseType?: ResponseType;
                                                                                                                                                                                                                                                                                  • The parsing method.

                                                                                                                                                                                                                                                                                    The promise also has .text(), .json() and .buffer() methods which return another Got promise for the parsed body.

                                                                                                                                                                                                                                                                                    It's like setting the options to {responseType: 'json', resolveBodyOnly: true} but without affecting the main Got promise.

                                                                                                                                                                                                                                                                                    __Note__: When using streams, this option is ignored.

                                                                                                                                                                                                                                                                                    Example 1

                                                                                                                                                                                                                                                                                    ``` (async () => { const responsePromise = got(url); const bufferPromise = responsePromise.buffer(); const jsonPromise = responsePromise.json();

                                                                                                                                                                                                                                                                                    const [response, buffer, json] = Promise.all([responsePromise, bufferPromise, jsonPromise]); // response is an instance of Got Response // buffer is an instance of Buffer // json is an object })(); ```

                                                                                                                                                                                                                                                                                    Example 2

                                                                                                                                                                                                                                                                                    ``` // This const body = await got(url).json();

                                                                                                                                                                                                                                                                                    // is semantically the same as this const body = await got(url, {responseType: 'json', resolveBodyOnly: true}); ```

                                                                                                                                                                                                                                                                                  type HookEvent

                                                                                                                                                                                                                                                                                  type HookEvent = 'afterResponse';

                                                                                                                                                                                                                                                                                    Package Files (5)

                                                                                                                                                                                                                                                                                    Dependencies (11)

                                                                                                                                                                                                                                                                                    Dev Dependencies (36)

                                                                                                                                                                                                                                                                                    Peer Dependencies (0)

                                                                                                                                                                                                                                                                                    No peer dependencies.

                                                                                                                                                                                                                                                                                    Badge

                                                                                                                                                                                                                                                                                    To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                                                                                                                                                    You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/got.

                                                                                                                                                                                                                                                                                    • Markdown
                                                                                                                                                                                                                                                                                      [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/got)
                                                                                                                                                                                                                                                                                    • HTML
                                                                                                                                                                                                                                                                                      <a href="https://www.jsdocs.io/package/got"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>