This topic provides sample code that shows how to return an output in JSON format.
Sample code
async function handler(event) {
const data = {
hello: "EdgeRoutine"
}
const json = JSON.stringify(data, null, 2)
return new Response(json, {
headers: {
"content-type": "application/json;charset=UTF-8"
}
})
}
addEventListener('fetch', (event) => {
event.respondWith(handler(event));
});