Deno LandDeno

Deploy Docs

FetchEvent

Deno Deploy dispatches a FetchEvent to your script when a new request is made towards your deployment. The event, represented by the string fetch, contains the details of the incoming request and methods to respond to the same request.

Properties

name type read only description
request Request true Represents the incoming request to your deployment.

Methods

name description
respondWith(response) A method to respond to the incoming request. The parameter response should be of type Response or a promise that resolves to a Response.

The waitUntil() method will be supported in future to execute code after returning a response.

Example

// We register our function to be called on "fetch" events.
addEventListener("fetch", (event: FetchEvent) => {
  // The FetchEvent has a property named `request` which holds
  // the details of the incoming request and is of type
  // `Request` of the Fetch API.
  const method = event.request.method;

  // We call the `respondWith` method to respond to the request.
  // The argument should either be a `Response` or a promise that
  // resolves to a Response.
  event.respondWith(new Response(`Hello. You made a ${method} request.`));
});

Please file an issue in our feedback repository if you find any problem in Deploy service or documentation.