Edit this page

up.network up.network.abort([matcher])
JavaScript function

Aborts pending requests.

The event up:request:aborted will be emitted.

The promise returned by up.request() will be rejected with an exception named AbortError:

try {
  let response = await up.request('/path')
  console.log(response.text)
} catch (err) {
  if (err.name == 'AbortError') {
    console.log('Request was aborted')
  }
}

Examples

Without arguments, this will abort all pending requests:

up.network.abort()

To abort a given up.Request object, pass it as the first argument:

let request = up.request('/path')
up.network.abort(request)

To abort all requests matching a condition, pass a function that takes a request and returns a boolean value. Unpoly will abort all request for which the given function returns true. E.g. to abort all requests with a HTTP method as GET:

up.network.abort((request) => request.method == 'GET')

Parameters

[matcher=true] up.RequestorbooleanorFunction(up.Request): boolean optional

If this argument is omitted, all pending requests are aborted.

This website uses cookies to improve usability and analyze traffic.
I accept or learn more