title | description | meta_tags | namespace | permalink | menu_namespace |
---|---|---|---|---|---|
JavaScript Examples - Return JSON |
Return a JSON directly from the Edge Function. |
edge computing, javascript, edge functions, return json |
documentation_products_edge_functions_javascript_examples_return_json |
documentation/products/edge-application/edge-functions/javascript-examples/return-json |
runtimeMenu |
Return a JSON directly from the Edge Function. Useful for building API or middlewares.
addEventListener("fetch", event => {
const data = {
hello: "world"
}
const json = JSON.stringify(data, null, 2)
return event.respondWith(
new Response(json, {
headers: {
"content-type": "application/json;charset=UTF-8"
}
})
)
})
import ContributorList from '~/components/ContributorList.astro'
Contributors Contributor