本页还没有译文
本页 8 段还没译成简体中文,下面显示的是英文原文。Fetch Handler
还没翻译译自英文(developers.cloudflare.com)本页 8 段都还没译
Background
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
-
requestRequest- The incoming HTTP request.
-
envobject- The bindings available to the Worker. As long as the environment has not changed, the same object (equal by identity) may be passed to multiple requests. You can also import
envfromcloudflare:workersto access bindings from anywhere in your code.
- The bindings available to the Worker. As long as the environment has not changed, the same object (equal by identity) may be passed to multiple requests. You can also import
-
ctx.waitUntil(promisePromise): void- Refer to
waitUntil.
- Refer to
-
ctx.passThroughOnException(): void- Refer to
passThroughOnException.
- Refer to
AI 翻译查看英文原文