• Version 3.0.0
  • Published
  • 75.9 kB
  • 2 dependencies
  • MIT license


npm i node-fetch
yarn add node-fetch
pnpm add node-fetch


A light-weight module that brings Fetch API to node.js



function fetch

fetch: (url: RequestInfo, init?: RequestInit) => Promise<Response>;

    function isRedirect

    isRedirect: (code: number) => boolean;


      class AbortError

      class AbortError extends Error {}

        property [Symbol.toStringTag]

        [Symbol.toStringTag]: string;

          property name

          name: string;

            property type

            type: string;

              class BodyMixin

              class BodyMixin {}


                constructor(body?: any, options?: { size?: number });

                  property body

                  readonly body: any;

                    property bodyUsed

                    readonly bodyUsed: boolean;

                      property size

                      readonly size: number;

                        method arrayBuffer

                        arrayBuffer: () => Promise<ArrayBuffer>;

                          method blob

                          blob: () => Promise<Blob>;

                            method buffer

                            buffer: () => Promise<Buffer>;

                              method json

                              json: () => Promise<unknown>;

                                method text

                                text: () => Promise<string>;

                                  class FetchError

                                  class FetchError extends Error {}


                                    message: string,
                                    type: string,
                                    systemError?: Record<string, unknown>

                                      property [Symbol.toStringTag]

                                      [Symbol.toStringTag]: string;

                                        property code

                                        code?: string;

                                          property errno

                                          errno?: string;

                                            property name

                                            name: string;

                                              property type

                                              type: string;

                                                class Headers

                                                class Headers {}
                                                • This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence.


                                                constructor(init?: HeadersInit);

                                                  method [Symbol.iterator]

                                                  [Symbol.iterator]: () => IterableIterator<[string, string]>;

                                                    method append

                                                    append: (name: string, value: string) => void;

                                                      method delete

                                                      delete: (name: string) => void;

                                                        method entries

                                                        entries: () => IterableIterator<[string, string]>;
                                                        • Returns an iterator allowing to go through all key/value pairs contained in this object.

                                                        method forEach

                                                        forEach: (
                                                        callbackfn: (value: string, key: string, parent: Headers) => void,
                                                        thisArg?: any
                                                        ) => void;

                                                          method get

                                                          get: (name: string) => string | null;

                                                            method has

                                                            has: (name: string) => boolean;

                                                              method keys

                                                              keys: () => IterableIterator<string>;
                                                              • Returns an iterator allowing to go through all keys of the key/value pairs contained in this object.

                                                              method raw

                                                              raw: () => Record<string, string[]>;
                                                              • Node-fetch extension

                                                              method set

                                                              set: (name: string, value: string) => void;

                                                                method values

                                                                values: () => IterableIterator<string>;
                                                                • Returns an iterator allowing to go through all values of the key/value pairs contained in this object.

                                                                class Request

                                                                class Request extends BodyMixin {}


                                                                  constructor(input: RequestInfo, init?: RequestInit);

                                                                    property headers

                                                                    readonly headers: Headers;
                                                                    • Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.

                                                                    property method

                                                                    readonly method: string;
                                                                    • Returns request's HTTP method, which is "GET" by default.

                                                                    property redirect

                                                                    readonly redirect: RequestRedirect;
                                                                    • Returns the redirect mode associated with request, which is a string indicating how redirects for the request will be handled during fetching. A request will follow redirects by default.

                                                                    property signal

                                                                    readonly signal: AbortSignal;
                                                                    • Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler.

                                                                    property url

                                                                    readonly url: string;
                                                                    • Returns the URL of request as a string.

                                                                    method clone

                                                                    clone: () => Request;

                                                                      class Response

                                                                      class Response extends BodyMixin {}


                                                                        constructor(body?: any, init?: ResponseInit);

                                                                          property headers

                                                                          readonly headers: Headers;

                                                                            property ok

                                                                            readonly ok: boolean;

                                                                              property redirected

                                                                              readonly redirected: boolean;

                                                                                property status

                                                                                readonly status: number;

                                                                                  property statusText

                                                                                  readonly statusText: string;

                                                                                    property type

                                                                                    readonly type: ResponseType;

                                                                                      property url

                                                                                      readonly url: string;

                                                                                        method clone

                                                                                        clone: () => Response;

                                                                                          method error

                                                                                          static error: () => Response;


                                                                                            interface Body

                                                                                            interface Body extends Pick<BodyMixin, keyof BodyMixin> {}

                                                                                              interface RequestInit

                                                                                              interface RequestInit {}

                                                                                                property agent

                                                                                                agent?: Agent | ((parsedUrl: URL) => Agent);

                                                                                                  property body

                                                                                                  body?: BodyInit | null;
                                                                                                  • A BodyInit object or null to set request's body.

                                                                                                  property compress

                                                                                                  compress?: boolean;

                                                                                                    property counter

                                                                                                    counter?: number;

                                                                                                      property follow

                                                                                                      follow?: number;

                                                                                                        property headers

                                                                                                        headers?: HeadersInit;
                                                                                                        • A Headers object, an object literal, or an array of two-item arrays to set request's headers.

                                                                                                        property highWaterMark

                                                                                                        highWaterMark?: number;

                                                                                                          property hostname

                                                                                                          hostname?: string;

                                                                                                            property insecureHTTPParser

                                                                                                            insecureHTTPParser?: boolean;

                                                                                                              property method

                                                                                                              method?: string;
                                                                                                              • A string to set request's method.

                                                                                                              property port

                                                                                                              port?: number;

                                                                                                                property protocol

                                                                                                                protocol?: string;

                                                                                                                  property redirect

                                                                                                                  redirect?: RequestRedirect;
                                                                                                                  • A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect.

                                                                                                                  property signal

                                                                                                                  signal?: AbortSignal | null;
                                                                                                                  • An AbortSignal to set request's signal.

                                                                                                                  property size

                                                                                                                  size?: number;

                                                                                                                    interface ResponseInit

                                                                                                                    interface ResponseInit {}

                                                                                                                      property headers

                                                                                                                      headers?: HeadersInit;

                                                                                                                        property status

                                                                                                                        status?: number;

                                                                                                                          property statusText

                                                                                                                          statusText?: string;

                                                                                                                            Type Aliases

                                                                                                                            type AbortSignal

                                                                                                                            type AbortSignal = {
                                                                                                                            readonly aborted: boolean;
                                                                                                                            addEventListener: (type: 'abort', listener: (this: AbortSignal) => void) => void;
                                                                                                                            removeEventListener: (
                                                                                                                            type: 'abort',
                                                                                                                            listener: (this: AbortSignal) => void
                                                                                                                            ) => void;

                                                                                                                              type BodyInit

                                                                                                                              type BodyInit = Blob | Buffer | URLSearchParams | NodeJS.ReadableStream | string;

                                                                                                                                type HeadersInit

                                                                                                                                type HeadersInit =
                                                                                                                                | Headers
                                                                                                                                | Record<string, string>
                                                                                                                                | Iterable<readonly [string, string]>
                                                                                                                                | Iterable<Iterable<string>>;

                                                                                                                                  type RequestInfo

                                                                                                                                  type RequestInfo = string | Request;

                                                                                                                                    type RequestRedirect

                                                                                                                                    type RequestRedirect = 'error' | 'follow' | 'manual';

                                                                                                                                      type ResponseType

                                                                                                                                      type ResponseType =
                                                                                                                                      | 'basic'
                                                                                                                                      | 'cors'
                                                                                                                                      | 'default'
                                                                                                                                      | 'error'
                                                                                                                                      | 'opaque'
                                                                                                                                      | 'opaqueredirect';

                                                                                                                                        Package Files (1)

                                                                                                                                        Dependencies (2)

                                                                                                                                        Dev Dependencies (16)

                                                                                                                                        Peer Dependencies (0)

                                                                                                                                        No peer dependencies.


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

                                                                                                                                        You may also use to create a custom badge linking to

                                                                                                                                        • Markdown
                                                                                                                                        • HTML
                                                                                                                                          <a href=""><img src="" alt=""></a>