node-fetch
- Version 3.3.2
- Published
- 107 kB
- 3 dependencies
- MIT license
Install
npm i node-fetch
yarn add node-fetch
pnpm add node-fetch
Overview
A light-weight module that brings Fetch API to node.js
Index
Functions
Classes
Interfaces
Type Aliases
Functions
function fetch
fetch: (url: URL | RequestInfo, init?: RequestInit) => Promise<Response>;
function isRedirect
isRedirect: (code: number) => boolean;
Classes
class AbortError
class AbortError extends Error {}
property [Symbol.toStringTag]
[Symbol.toStringTag]: string;
property name
name: string;
property type
type: string;
class FetchError
class FetchError extends Error {}
constructor
constructor( 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
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
constructor(input: URL | 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 referrer
readonly referrer: string;
A string whose value is a same-origin URL, "about:client", or the empty string, to set request’s referrer.
property referrerPolicy
readonly referrerPolicy: ReferrerPolicy;
A referrer policy to set request’s referrerPolicy.
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
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;
method json
static json: (data: any, init?: ResponseInit) => Response;
method redirect
static redirect: (url: string, status?: number) => Response;
Interfaces
interface Body
interface Body extends Pick<BodyMixin, keyof BodyMixin> {}
interface RequestInit
interface RequestInit {}
property agent
agent?: RequestOptions['agent'] | ((parsedUrl: URL) => RequestOptions['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 referrer
referrer?: string;
A string whose value is a same-origin URL, "about:client", or the empty string, to set request’s referrer.
property referrerPolicy
referrerPolicy?: ReferrerPolicy;
A referrer policy to set request’s referrerPolicy.
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 BodyInit
type BodyInit = | Blob | Buffer | URLSearchParams | FormData | NodeJS.ReadableStream | string;
type HeadersInit
type HeadersInit = | Headers | Record<string, string> | Iterable<readonly [string, string]> | Iterable<Iterable<string>>;
type ReferrerPolicy
type ReferrerPolicy = | '' | 'no-referrer' | 'no-referrer-when-downgrade' | 'same-origin' | 'origin' | 'strict-origin' | 'origin-when-cross-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
type RequestInfo
type RequestInfo = string | Request;
type RequestRedirect
type RequestRedirect = 'error' | 'follow' | 'manual';
Package Files (1)
Dependencies (3)
Dev Dependencies (16)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto 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/node-fetch
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/node-fetch)
- HTML<a href="https://www.jsdocs.io/package/node-fetch"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3306 ms. - Missing or incorrect documentation? Open an issue for this package.