In this example, an Edge Function is used to generate a JSON object, and the JSON object is accessed and previewed from a browser.
const JSON_DATA = {
content: 'Hello World',
};
async function handleRequest() {
return new Response(JSON.stringify(JSON_DATA), {
headers: {
'content-type': 'application/json; charset=UTF-8',
},
});
}
addEventListener('fetch', event => {
event.respondWith(handleRequest());
});