Edit this page

API class up.Request

A normalized description of an HTTP request.

You can queue a request using the up.request() method:

let request = up.request('/foo')
console.log(request.url)

// A request object is also a promise for its response
let response = await request
console.log(response.text)

Features

All features

JS
up.Request.prototype.abort([options]) experimental

Aborts this request.

JS
up.Request.prototype.background experimental

Whether this request is loading in the background.

JS
up.Request.prototype.badResponseTime experimental

The number of milliseconds after which this request can cause an up:network:late event.

JS
up.Request.prototype.contentType stable

The format in which the request params will be encoded.

JS
up.Request.prototype.context experimental

The context of the layer targeted by this request.

JS
up.Request.prototype.failContext experimental

The context of the layer targeted by this request in case the server responds with an error code.

JS
up.Request.prototype.failLayer experimental

The layer targeted by this request in case the server responds with an error code.

JS
up.Request.prototype.failMode stable

The mode of the layer targeted by this request in case the server responds with an error code.

JS
up.Request.prototype.failTarget stable

The CSS selector targeted by this request in case the server responds with an error code.

JS
up.Request.prototype.fragment experimental

Returns the fragment matched by this request's target selector.

JS
up.Request.prototype.fragments experimental

Returns the fragments matched by this request's target selector.

JS
up.Request.prototype.hash stable

The hash component of this request's URL.

JS
up.Request.prototype.header(name) stable

Returns the HTTP request header value with the given name.

JS
up.Request.prototype.headers stable

An object of HTTP headers that will be sent with this request.

JS
up.Request.prototype.layer experimental

The layer targeted by this request.

JS
up.Request.prototype.loadPage() deprecated

Loads this request object as a full-page request, replacing the entire browser environment with a new page from the server response.

JS
up.Request.prototype.loadPage() experimental

Loads this request object as a full-page request, replacing the entire browser environment with a new page from the server response.

JS
up.Request.prototype.method stable

The HTTP method for the request.

JS
up.Request.prototype.mode stable

The mode of the layer targeted by this request.

JS
up.Request.prototype.origin experimental

The element that triggered the request.

JS
up.Request.prototype.params stable

Parameters that should be sent as the request's payload.

JS
up.Request.prototype.payload stable

The payload that the request will encode into its body.

JS
up.Request.prototype.preload deprecated

Whether this request is preloading content.

JS
up.Request.prototype.target stable

The CSS selector targeted by this request.

JS
up.Request.prototype.then(onFulfilled, onRejected) stable

An up.Request is also a promise for the server response.

JS
up.Request.prototype.timeout stable

A timeout in milliseconds.

JS
up.Request.prototype.url stable

The requested URL.

JS
up.Request.prototype.wrapMethod stable

Whether to wrap non-standard HTTP methods in a POST request.

JS
up.Request.prototype.xhr stable

Returns the underlying XMLHttpRequest instance.