Static Response
This script returns the same response for every request, a { "hello": "world" }
json object with status code 200.
addEventListener("fetch", event => {
event.respondWith(handleRequest(event.request));
});
async function handleRequest() {
return new Response(JSON.stringify({ hello: "world" }), {
status: 200,
headers: { "Content-Type": "application/json" }
});
}
Updated over 3 years ago