docs: fix form data page (#3329)
Fixes https://github.com/denoland/fresh/issues/3320
This commit is contained in:
@@ -23,11 +23,11 @@ This example demonstrates how to handle `application/x-www-form-urlencoded`
|
|||||||
import { define } from "../utils.ts";
|
import { define } from "../utils.ts";
|
||||||
|
|
||||||
export const handlers = define.handlers({
|
export const handlers = define.handlers({
|
||||||
async GET(req, ctx) {
|
async GET(ctx) {
|
||||||
return await ctx.render();
|
return { data: {} };
|
||||||
},
|
},
|
||||||
async POST(req, ctx) {
|
async POST(ctx) {
|
||||||
const form = await req.formData();
|
const form = await ctx.req.formData();
|
||||||
const email = form.get("email")?.toString();
|
const email = form.get("email")?.toString();
|
||||||
|
|
||||||
// Add email to list.
|
// Add email to list.
|
||||||
@@ -68,11 +68,11 @@ that this time, we have to explicitly declare the form's encoding to be
|
|||||||
import { define } from "../utils.ts";
|
import { define } from "../utils.ts";
|
||||||
|
|
||||||
export const handler = define.handlers({
|
export const handler = define.handlers({
|
||||||
async GET(req, ctx) {
|
async GET(ctx) {
|
||||||
return { data: { message: null } };
|
return { data: { message: null } };
|
||||||
},
|
},
|
||||||
async POST(req, ctx) {
|
async POST(ctx) {
|
||||||
const form = await req.formData();
|
const form = await ctx.req.formData();
|
||||||
const file = form.get("my-file") as File;
|
const file = form.get("my-file") as File;
|
||||||
|
|
||||||
if (!file) {
|
if (!file) {
|
||||||
|
|||||||
Reference in New Issue
Block a user