JavaScript Runtime APIs - AddEventListener

How it works

The addEventListener function defines the trigger for the execution of JavaScript code to receive the request data. The event listener type is fetch and gets the fetchEvent

Syntax

addEventListener(type, listener)

Properties

  • type: string - the supported type is fetch.

  • listener: function - the function that handles incoming Azion Cells events.

Example

addEventListener("fetch", event => {
return event.respondWith(
new Response("Hello world")
)
})

For more information on addEventListener visit MDN Web Docs.


Contributors