Skip to content

Commit dc56506

Browse files
Refactor form handling to use define.handlers
1 parent ea6c48c commit dc56506

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

www/components/homepage/FormsSection.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,21 @@ import { ExampleArrow } from "../homepage/ExampleArrow.tsx";
88
import { FancyLink } from "../FancyLink.tsx";
99
import { FormSubmitDemo } from "../../islands/FormSubmitDemo.tsx";
1010

11-
const routingCode = `import { Handlers } from "$fresh/server.ts";
11+
const routingCode = `import { define } from "../utils.ts";
1212
13-
export const handler: Handlers = {
14-
async POST(req) {
15-
const form = await req.formData();
13+
export const handler = define.handlers({
14+
async POST(ctx) {
15+
const form = await ctx.req.formData();
1616
1717
// Do something with the form data here,
1818
// then redirect user to thank you page
1919
20-
const headers = new Headers();
21-
headers.set("location", "/thanks");
2220
return new Response(null, {
2321
status: 303,
24-
headers,
22+
headers: { location: "/thanks" },
2523
});
2624
},
27-
};`;
25+
});`;
2826

2927
export function FormsSection() {
3028
return (

0 commit comments

Comments
 (0)