Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { blob } from "https://esm.town/v/std/blob?v=11";
import { email } from "https://esm.town/v/std/email?v=11";
export const renderFormAndSaveData = async (req: Request) => {
const origin = req.headers.get("origin");
// Pick out the form data
const formData = await req.formData();
const emailAddress = formData.get("email") as string;
const name = formData.get("name") as string;
const message = formData.get("message") as string;
email({ text: `${emailAddress}\n\n${name}\n\n${message}`, subject: "Contact Message" });
// Store form data
return Response.redirect(`${origin}/contact-confirmation`, 302);
};
jcoleman-handledeerspringcontactform.web.val.run
June 13, 2024