Return JSON
This example returns JSON directly from the edge computing script. You can use this example to build APIs or middleware for your application.
addEventListener("fetch", (event) => {
event.respondWith(handleRequest(event.request));
});
async function handleRequest(request) {
const data = {
hello: "world",
};
return Response.json(data);
}