Return JSON
Return JSON directly from a Worker script, useful for building APIs and middleware.
Run Workerexport default { async fetch(request) { const data = { hello: "world", };
return Response.json(data); },
};
export default { async fetch(request: Request) { const data = { hello: "world", };
return Response.json(data); },
} satisfies ExportedHandler;