react hook form with server action gives me the error fromdata.get is not a function #11762
Unanswered
tibo-koninckx
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a form with a server action to send data to my database. For my database I use postgresQL and drizzle orm.

When I try to send my form with my server action and react hook, I get this error:
So I created an onSubmit function for react hook form that I use in my form:
const onSubmit = handleSubmit(data => { startTransition(() => { sendInvoiceData(data); }); });
and i use it by this way in my form tag:
<form onSubmit={onSubmit}>
To extract data from my form and send it to the database, I retrieve my data this way:
export async function sendInvoiceData(formdata: FormData) { const {userId} = auth(); const newInvoice: Invoice = { invoice_number: formdata.get("invoice_number") as string, invoice_date: new Date(formdata.get("invoice_date") as string).toISOString().split('T')[0], due_date: new Date(formdata.get("due_date") as string).toISOString().split('T')[0], send: formdata.has("send"), paid: formdata.has("paid"), valuta: formdata.get("valuta") as string, total_amount: Number(formdata.get("total_amount")), clientId: Number(formdata.get("client_id")), };
it always gives me the error: formdata.get is not a function.
How can i fix it, i use Nextjs with Typescript
Beta Was this translation helpful? Give feedback.
All reactions