Edit this page

up.Request up.Request.prototype.then(onFulfilled, onRejected)
Class method

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

A request is fulfilled with an up.Response when the server sends a response with a status code of 2xx or 304.

The promise will reject for responses with a failed HTTP status, when the request is aborted or when there is network issue.

Example

try {
  let response = await up.request('foo')
  console.log('Successful response:', response.text)
} catch (error) {
  if (error instanceof up.Request) {
    console.log('Response with error code:', response.text)
  } else {
    console.log("Other error during request: ", error)
  }
}

Parameters

onFulfilled Function(up.Response)
onRejected Function(up.ResponseorError)

Return value

A promise that fulfills when the server response was fully loaded.