跳转到主要内容

Fetch Handler

Incoming HTTP requests to a Worker are passed to the fetch() handler as a Request object. To respond to the request with a response, return a Response object:

export default {
	async fetch(request, env, ctx) {
		return new Response('Hello World!');
	},
};

:::note

The Workers runtime does not support XMLHttpRequest (XHR). Learn the difference between XMLHttpRequest and fetch() in the MDN documentation.

:::

Parameters

  • request Request

    • The incoming HTTP request.
  • env object

  • ctx.waitUntil(promisePromise) : void

  • ctx.passThroughOnException() : void