Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix formData code snippet in route handler docs #52532

Merged

Conversation

joulev
Copy link
Contributor

@joulev joulev commented Jul 11, 2023

Why?

The code snippet in the Route handler formData documentation

import { NextResponse } from 'next/server'
 
export async function POST(request: Request) {
  const formData = await request.formData()
  return NextResponse.json({ formData })
}

is slightly wrong, because formData is not a plain object and hence return NextResponse.json({ formData }) doesn't actually work.

Since we are already in the topic of parsing formData, I also added a mention on zod-form-data which can be used to validate the form and parse it to non-string formats such as number.

@joulev joulev requested review from a team as code owners July 11, 2023 03:18
@joulev joulev requested review from S3Prototype and steven-tey July 11, 2023 03:18
@ijjk
Copy link
Member

ijjk commented Jul 11, 2023

Allow CI Workflow Run

  • approve CI run for commit: d3f0b78

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

@kodiakhq kodiakhq bot merged commit a0ea5f2 into vercel:canary Jul 22, 2023
@joulev joulev deleted the fix-form-data-route-handler-documentation branch July 23, 2023 01:58
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants