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.
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)
}
}
A promise that fulfills when the server response was fully loaded.