Skip to content

Return JSON

Last reviewed: 9 months ago

Return JSON directly from a Worker script, useful for building APIs and middleware.

export default {
async fetch(request) {
const data = {
hello: "world",
};
return Response.json(data);
},
};
Run Worker in Playground