Request

This Fetch API interface represents a resource request.

class Request implements Body {
constructor(input: RequestInfo | URL, init?: RequestInit);
readonly body: ReadableStream<Uint8Array> | null;
readonly bodyUsed: boolean;
readonly cache: RequestCache;
readonly credentials: RequestCredentials;
readonly destination: RequestDestination;
readonly headers: Headers;
readonly integrity: string;
readonly isHistoryNavigation: boolean;
readonly isReloadNavigation: boolean;
readonly keepalive: boolean;
readonly method: string;
readonly mode: RequestMode;
readonly redirect: RequestRedirect;
readonly referrer: string;
readonly referrerPolicy: ReferrerPolicy;
readonly signal: AbortSignal;
readonly url: string;
 
arrayBuffer(): Promise<ArrayBuffer>;
blob(): Promise<Blob>;
clone(): Request;
formData(): Promise<FormData>;
json(): Promise<any>;
text(): Promise<string>;
}

§Implements

§Constructors

§
new Request(input: RequestInfo | URL, init?: RequestInit)
[src]

§Properties

§
body: ReadableStream<Uint8Array> | null
[src]

A simple getter used to expose a ReadableStream of the body contents.

§
bodyUsed: boolean
[src]

Stores a Boolean that declares whether the body has been used in a request yet.

§

Returns the cache mode associated with request, which is a string indicating how the request will interact with the browser's cache when fetching.

§

Returns the credentials mode associated with request, which is a string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL.

§

Returns the kind of resource requested by request, e.g., "document" or "script".

§
headers: Headers
[src]

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.

§
integrity: string
[src]

Returns request's subresource integrity metadata, which is a cryptographic hash of the resource being fetched. Its value consists of multiple hashes separated by whitespace. [SRI]

§
isHistoryNavigation: boolean
[src]

Returns a boolean indicating whether or not request is for a history navigation (a.k.a. back-forward navigation).

§
isReloadNavigation: boolean
[src]

Returns a boolean indicating whether or not request is for a reload navigation.

§
keepalive: boolean
[src]

Returns a boolean indicating whether or not request can outlive the global in which it was created.

§
method: string
[src]

Returns request's HTTP method, which is "GET" by default.

§

Returns the mode associated with request, which is a string indicating whether the request will use CORS, or will be restricted to same-origin URLs.

§

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.

§
referrer: string
[src]

Returns the referrer of request. Its value can be a same-origin URL if explicitly set in init, the empty string to indicate no referrer, and "about:client" when defaulting to the global's default. This is used during fetching to determine the value of the Referer header of the request being made.

§
referrerPolicy: ReferrerPolicy
[src]

Returns the referrer policy associated with request. This is used during fetching to compute the value of the request's referrer.

§

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

§
url: string
[src]

Returns the URL of request as a string.

§Methods

§
arrayBuffer(): Promise<ArrayBuffer>
[src]

Takes a Request stream and reads it to completion. It returns a promise that resolves with an ArrayBuffer.

§
blob(): Promise<Blob>
[src]

Takes a Request stream and reads it to completion. It returns a promise that resolves with a Blob.

§
formData(): Promise<FormData>
[src]

Takes a Request stream and reads it to completion. It returns a promise that resolves with a FormData object.

§
json(): Promise<any>
[src]

Takes a Request stream and reads it to completion. It returns a promise that resolves with the result of parsing the body text as JSON.

§
text(): Promise<string>
[src]

Takes a Request stream and reads it to completion. It returns a promise that resolves with a USVString (text).