jamiedubs-datademo.web.val.run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// hello i am a simple demo of using GET/POST + Content-Type header to handle things differently
// I'm also gonna show VALTOWN BLOBS:
// import { blob } from "https://esm.town/v/std/blob?v=10";
// await blob.setJSON(key, newData);
// const data = await blob.getJSON(key);
export const dataDemo = async (req: Request) => {
if (req.method == "GET") {
return Response.json({ ok: true });
} else if (req.method == "POST") {
const contentType = req.headers.get("Content-Type");
const body = await req.text();
return Response.json({ contentType, body });
}
};
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
December 20, 2023