up.Request.prototype.then(onFulfilled, onRejected)
Instance 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 an HTTP error status, when the request is aborted or when there is a network issue.
Example
try {
let response = await up.request('foo')
console.log('Successful response:', response.text)
} catch (error) {
if (error instanceof up.Response) {
console.log('Response with error code:', error.text)
} else {
console.log("Other error during request:", error)
}
}
Parameters
onFulfilled
required
Type: Function(up.Response)
onRejected
required
Type: Function(up.Response|Error)
Return value
A promise that fulfills when the server response was fully loaded.
Type: Promise<up.Response>