Request
Types
bodyInit
type bodyInit = BodyInit.theadersInit
type headersInit = HeadersInit.trequestInit
type requestInit = FetchTypes.requestInitRecord fields
method
A string to set request's method.
headers
A Headers object, an object literal, or an array of two-item arrays to set request's headers.
referrer
A string whose value is a same-origin WebApiURL, "about:client", or the empty string, to set request's referrer.
referrerPolicy
A referrer policy to set request's referrerPolicy.
mode
A string to indicate whether the request will use CORS, or will be restricted to same-origin URLs. Sets request's mode.
credentials
A string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. Sets request's credentials.
cache
A string indicating how the request will interact with the browser's cache to set request's cache.
redirect
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.
integrity
A cryptographic hash of the resource to be fetched by request. Sets request's integrity.
keepalive
A boolean to set request's keepalive.
signal
An AbortSignal to set request's signal.
priority
window
Can only be null. Used to disassociate request from any Window.
t
type t = FetchTypes.request = { method: string, url: string, headers: FetchTypes.headers, destination: FetchTypes.requestDestination, referrer: string, referrerPolicy: FetchTypes.referrerPolicy, mode: FetchTypes.requestMode, credentials: FetchTypes.requestCredentials, cache: FetchTypes.requestCache, redirect: FetchTypes.requestRedirect, integrity: string, keepalive: bool, signal: EventTypes.abortSignal, body: Null.t<FileTypes.readableStream<array<int>>>, bodyUsed: bool,}Record fields
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. Read more on MDN
destination
Returns the kind of resource requested by request, e.g., "document" or "script". Read more on MDN
referrer
Returns the referrer of request. Its value can be a same-origin WebApiURL 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.
Read more on MDN
referrerPolicy
Returns the referrer policy associated with request. This is used during fetching to compute the value of the request's referrer. Read more on MDN
mode
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. Read more on MDN
credentials
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. Read more on MDN
cache
Returns the cache mode associated with request, which is a string indicating how the request will interact with the browser's cache when fetching. Read more on MDN
redirect
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. Read more on MDN
integrity
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] Read more on MDN
keepalive
Returns a boolean indicating whether or not request can outlive the global in which it was created. Read more on MDN
signal
Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler. Read more on MDN
Values
arrayBuffer
let arrayBuffer: t => promise<ArrayBuffer.t>bytes
let bytes: t => promise<array<int>>formData
let formData: t => promise<FormData.t>fromRequest
let fromRequest: (t, ~init: requestInit=?) => tfromURL
let fromURL: (string, ~init: requestInit=?) => tjson
let json: t => promise<JSON.t>