JavaScript Runtime APIs - AddEventListener
How it works
Section titled How it worksThe 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
Section titled Syntax addEventListener(type, listener)
Properties
Section titled Properties-
type:
string
- the supported type isfetch
. -
listener:
function
- the function that handles incoming Azion Cells events.
Example
Section titled Example addEventListener("fetch", event => { return event.respondWith( new Response("Hello world") ) })
For more information on addEventListener visit MDN Web Docs.