FetchRequest

interface FetchRequest

Fetch: Request.

Specifies the interface defined by the Fetch API Specification, "Request," which represents an HTTP request created or received by the JavaScript runtime. Fetch requests model regular HTTP concepts such as the HTTP method, path, and parameters, augmenting with structure from classes like FetchHeaders and URLSearchParams.

From MDN: "The Request interface of the Fetch API represents a resource request. You can create a new Request object using the Request() constructor, but you are more likely to encounter a Request object being returned as the result of another API operation, such as a service worker FetchEvent.request."

 

Use as execution inputs

FetchRequest-shaped objects may be used with VM execution inputs in order to invoke a guest VM interface each time a request is received ("server-style invocation"). There are multiple implementations of FetchRequest from a server perspective.

 

Use from a guest context

Fetch requests can be created in applicable guest VM environments, such as JavaScript via the Request(...) constructor, available globally. An instantiated Request can then be passed to fetch to initiate an HTTP request (host permissions permitting).

Inheritors

Types

Link copied to clipboard
object Defaults

Default values applied to FetchRequest interfaces.

Properties

Link copied to clipboard
abstract val body: ReadableStream?

Specifies, if any, a ReadableStream which holds the body of a FetchRequest. Body data may only be provided when the method for the request allows a body, such as POST, PUT, and so forth.

Link copied to clipboard
abstract val bodyUsed: Boolean

If the body for this request has already been consumed, this property must return true; if false, the body is still buffered and may be queried.

Link copied to clipboard
open val cache: String

Specifies the cache mode for the request. The default value is default, which indicates that the browser or executing engine should use sensible and safe defaults.

Link copied to clipboard

Specifies whether user credentials should be sent with the request. The default value is omit, which indicates that user credentials (or any other credentials) should be omitted. Server-side, there are no "default" rules for authorization material present on a request; what you send is what is sent, so this property does nothing.

Link copied to clipboard
abstract val destination: String

Describes the destination or use profile for the fetched data in a given fetch request/response cycle.

Link copied to clipboard
abstract val headers: FetchHeaders

Provides a typed view of fetch headers on top of this request, via FetchHeaders, which behaves as a specialized JavaScript-compatible multi-map. Multiple header values can be set per header key, if desired, which can be safely combined into a comma-separated header value group upon render.

Link copied to clipboard
open val integrity: String?

Provides a calculated integrity hash value which is expected to be found when calculating a similar value for any data returned from a Request cycle. The integrity value is expected to be well-formed, with a prefix that describes the algorithm used to calculate the hash.

Link copied to clipboard
open val method: String

Provides the request HTTP method name associated with this request (defaulting to GET). This value may be any of the standard HTTP method names, or a custom method name, as documented/applicable.

Link copied to clipboard
open val mode: String

Specifies the operating mode for this request, which is derived from the source of the request and applicable security context. This property is typically not used server-side.

Link copied to clipboard
open val priority: String

Specifies the operating priority for this request, where applicable/supported. This property gives the developer a chance to express the relative priority of a given request, or to understand the estimated priority for an incoming request.

Link copied to clipboard
open val redirect: String

Describes how redirects are to be handled in response to this request. Only makes sense when expressed on an outbound fetch request instance.

Link copied to clipboard
open val referrer: String?

Indicates the referrer value for an outgoing request in a browser. Typically not used server-side.

Link copied to clipboard

Indicates the referrer-policy which is active for this request. Typically not used server-side.

Link copied to clipboard
abstract val url: String

Indicates the request URL, to the best of operating runtime knowledge. In all instances, an absolute string URL is expected as the return result.