You can use Edge Functions to return a JSON response by returning context.json()
with a JavaScript object — no need to
JSON.stringify
!
Edge Functions are files held in the netlify/edge-functions
directory.
import type { Context } from "https://edge.netlify.com";
export default async (request: Request, context: Context) => {
return context.json({ hello: "world" });
};
You can deploy this and all the other examples in this repo as a site of your own to explore and experiment with, by clicking this button.