Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
f163dd09
Unverified
Commit
f163dd09
authored
Nov 16, 2023
by
Joshua Santos
Committed by
GitHub
Nov 16, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
examples: fix unhandled runtime error for forms (#56600)
Co-authored-by:
Lee Robinson
<
me@leerob.io
>
parent
70389d0c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletion
+7
-1
actions.ts
examples/next-forms/app/actions.ts
+7
-1
No files found.
examples/next-forms/app/actions.ts
View file @
f163dd09
...
...
@@ -13,10 +13,16 @@ export async function createTodo(prevState: any, formData: FormData) {
const
schema
=
z
.
object
({
todo
:
z
.
string
().
min
(
1
),
})
const
data
=
schema
.
p
arse
({
const
parse
=
schema
.
safeP
arse
({
todo
:
formData
.
get
(
'todo'
),
})
if
(
!
parse
.
success
)
{
return
{
message
:
'Failed to create todo'
}
}
const
data
=
parse
.
data
try
{
await
sql
`
INSERT INTO todos (text)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment