fetch
request events are supported currently. If a fetch
event occurs after a fetch
event listener is registered, the event listener generates a FetchEvent object to process the HTTP request.function addEventListener(type: string, listener: (event: FetchEvent) => void): void;
Parameter | Type | Required | Description |
type | string | Yes | Event type. Only fetch request events are supported.If you specify a request event type other than fetch , the Edge Functions engine throws an Error exception. |
listener | Yes | Event listener that is used to process event callbacks. You can register a fetch event listener to generate FetchEvent objects. |
// Register a fetch event listener.addEventListener('fetch', (event) => {// Respond to the client.event.respondWith(new Response('Hello World!'));});
Was this page helpful?