Skip to content

Commit

Permalink
docs: Fix arguments for route component in Upload example (denoland#2396
Browse files Browse the repository at this point in the history
)

Closes denoland#2395
  • Loading branch information
CAYdenberg authored Apr 8, 2024
1 parent 425032a commit 5d490c8
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions docs/latest/concepts/forms.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,17 @@ File uploads can be handled in a very similar manner to the example above. Note
that this time, we have to explicitly declare the form's encoding.

```tsx routes/subscribe.tsx
import { Handlers, type RouteContext } from "$fresh/server.ts";
import { Handlers, type PageProps } from "$fresh/server.ts";

export const handler: Handlers = {
interface Props {
message: string | null;
}

export const handler: Handlers<Props> = {
async GET(req, ctx) {
return await ctx.render();
return await ctx.render({
message: null,
});
},
async POST(req, ctx) {
const form = await req.formData();
Expand All @@ -85,13 +91,13 @@ export const handler: Handlers = {
console.log(contents);

return ctx.render({
message: `${file.name} uploaded!`,
message: `${name} uploaded!`,
});
},
};

export default function Upload(req: Request, ctx: RouteContext) {
const { message } = ctx.data;
export default function Upload(props: PageProps<Props>) {
const { message } = props.data;
return (
<>
<form method="post" encType="multipart/form-data">
Expand Down

0 comments on commit 5d490c8

Please sign in to comment.