---
name: "up:request:load"
area: "API"
kind: "DOM event"
parent: "up.network module"
url: "https://unpoly.com/api/up:request:load"
---
<nav aria-label="Unpoly docs">[All docs](https://unpoly.com/index.md) · [up.network module](https://unpoly.com/api/up.network.md)</nav>

# up:request:load

This event is [emitted](https://unpoly.com/api/up.emit.md) before a [request](https://unpoly.com/api/up.request.md) is sent over the network.

Only requests that are sent via Unpoly features (like [`[up-follow]`](https://unpoly.com/api/up-follow.md) or [`up.request()`](https://unpoly.com/api/up.request.md)) will trigger this event. When making requests using `fetch()` or [`XMLHttpRequest`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest), no event is emitted.

The event is emitted on the layer that caused the request.

<nav aria-label="Guides">

- [Learn: Network & caching](https://unpoly.com/learn/network.md)

</nav>

## Changing requests before loading {#changing-requests}

Listeners to `up:request:load` can inspect or mutate the [request options](https://unpoly.com/api/up.request.md#parameters-request) before the request is loaded.

For example, this listener changes requests to `/stocks` to include a custom header and have a timeout of 10 seconds:

```js
up.on('up:request:load', (event) => {
  if (event.request.url === '/stocks') {
    event.request.headers['X-Client-Time'] = Date.now().toString()
    event.request.timeout = 10_000
  }
})
```

---

## Event properties {#properties}

### event.request {#event.request}

(required)

The request that will be sent.

Listeners can [inspect or mutate request options](#changing-requests) before the request is sent.

Type: [up.Request](https://unpoly.com/api/up.Request.md)

### [event.layer] {#event.layer}

(optional)

The [layer](https://unpoly.com/api/up.layer.md) this request is associated with.

If this request is intended to update an existing fragment, this is that fragment's layer.

If this request is intended to [open an overlay](https://unpoly.com/learn/opening-overlays.md), the associated layer is the future overlay's parent layer.

Type: [up.Layer](https://unpoly.com/api/up.Layer.md)

### [event.origin] {#event.origin}

(optional)

The link or form element that caused the request.

Type: [Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)

### event.preventDefault() {#event.preventDefault}

(required)

[Aborts](https://unpoly.com/api/up.Request.prototype.abort.md) the request before it is sent.

