Skip to main content

IsomorphicFetchEvent

Overview

Represents an event dispatched when a network request is made.

Keywork uses IsomorphicFetchEvent as a context object for each incoming request made to a RequestRouter. You can use this object to access the incoming request, the environment variables, and the data passed to the Worker.

Generally, IsomorphicFetchEvent should not be instantiated directly, but rather is automatically created by the RequestRouter when a request is received.

Usage

import { IsomorphicFetchEvent } from 'keywork/events/classes'

Type parameters

NameType
BoundAliases{}
ExpectedParams{}
Data{}

Hierarchy

Implements

  • EventInit

Constructors

constructor

new IsomorphicFetchEvent

new IsomorphicFetchEvent<BoundAliases, ExpectedParams, Data>(eventType?, __namedParameters)

Type parameters

NameType
BoundAliases{}
ExpectedParams{}
Data{}

Parameters

NameTypeDefault value
eventTypestring'fetch'
__namedParametersIsomorphicFetchEventInit<BoundAliases, Data>undefined

Overrides

IsomorphicExtendableEvent.constructor

Defined in

events/classes/IsomorphicFetchEvent.ts:55

Properties

clientId

readonly clientId: `string`

Defined in

events/classes/IsomorphicFetchEvent.ts:32

data

data: `Data`

Defined in

events/classes/IsomorphicFetchEvent.ts:38

env

env: `BoundAliases`

Defined in

events/classes/IsomorphicFetchEvent.ts:37

handled

readonly handled: `Promise<undefined>`

Defined in

events/classes/IsomorphicFetchEvent.ts:34

match

match: `URLPatternResult`

The result of the URL pattern match from the RequestRouter.

Defined in

events/classes/IsomorphicFetchEvent.ts:44

originalURL

originalURL: `string`

The original URL of the request.

Defined in

events/classes/IsomorphicFetchEvent.ts:54

params

params: `ExpectedParams`

Defined in

events/classes/IsomorphicFetchEvent.ts:39

preloadResponse

readonly preloadResponse: `Promise<any>`

Defined in

events/classes/IsomorphicFetchEvent.ts:35

request

request: `Request`

The incoming request received by the Worker.

Defined in

events/classes/IsomorphicFetchEvent.ts:49

resultingClientId

readonly resultingClientId: `string`

Defined in

events/classes/IsomorphicFetchEvent.ts:33

Methods

dispose

dispose

(): `void`

Returns

void

Inherited from

IsomorphicExtendableEvent.dispose

Defined in

events/classes/IsomorphicExtendableEvent.ts:60

flushTasks

flushTasks

(this): `Promise<void>`

Awaits all tasks remaining in the queue.

Parameters

NameType
thisIsomorphicExtendableEvent

Returns

Promise<void>

Inherited from

IsomorphicExtendableEvent.flushTasks

Defined in

events/classes/IsomorphicExtendableEvent.ts:54

passThroughOnException

passThroughOnException

(): `void`

Prevents a runtime error response when the Worker script throws an unhandled exception.

Deprecated

The passThroughOnException method is only applicable to Service Workers

See

Returns

void

Defined in

events/classes/IsomorphicFetchEvent.ts:89

respondWith

respondWith

(_response): `void`

Intercepts the request and allows the Worker to send a custom response.

Deprecated

The respondWith method is only applicable to Service Workers.

See

Parameters

NameType
_responseResponse

Returns

void

Defined in

events/classes/IsomorphicFetchEvent.ts:75

waitUntil

waitUntil

(this, nonBlockingTask): `void`

Extends the lifetime of the route handler, even after a Response is sent to a client.

Parameters

NameTypeDescription
thisIsomorphicExtendableEvent-
nonBlockingTaskPromise<any>

Returns

void

Inherited from

IsomorphicExtendableEvent.waitUntil

Defined in

events/classes/IsomorphicExtendableEvent.ts:33