Not seeing any data from Server Action Form
Answered
Oak apple gall wasp posted this in #help-forum
Oak apple gall waspOP
Hey there, as the title indicates, I set up a Server Action form and added an action function - the code is as below:
Console logs:
What am I missing? How do I access the data correctly?
export async function NewsLetterSignUp() {
'use server'
const waitingList = async (input_value) => {
"use server"
console.log(input_value)
}
return (
(<div className="flex flex-col min-h-[100dvh]">
<main className="flex-1">
<section className="w-full py-12 md:py-24 lg:py-32 xl:py-48">
<div
className="container flex flex-col items-center justify-center gap-4 px-4 text-center md:px-6">
<div className="space-y-3">
<h1 className="text-3xl font-bold tracking-tighter sm:text-4xl md:text-5xl">
Embrace the Future of Creativity
</h1>
<p
className="max-w-[700px] text-gray-500 md:text-xl/relaxed lg:text-base/relaxed xl:text-xl/relaxed dark:text-gray-400">
We are currently in Dark Mode and have no set date when we will begin rolling out features publicly, but if you are
eager to be one of the very first to experience the Future of Creative Competition, Collaboration, and Community,
you can sign up here on our Waiting List. We will reach out as features are rolled out to be tested.
</p>
</div>
<form action={waitingList} className="flex flex-col gap-4 max-w-sm w-full">
<Input placeholder="Enter your email" type="email" />
<Button type="submit" size="lg">Join our Waiting List</Button>
</form>
</div>
</section>
</main>
</div>)
);
}Console logs:
FormData { [Symbol(state)]: [] }What am I missing? How do I access the data correctly?
Answered by joulev
1. remove the
2. add
"use server" in the second line, it's not necessary2. add
name to the <Input>: <Input name="email" placeholder="Enter your email" type="email" />7 Replies
Answer
Oak apple gall waspOP
Awesome! Thank you!
Is that the same for things like username/password fields for login? How do I prevent passwords being transmitted in plain text?
@Oak apple gall wasp Is that the same for things like username/password fields for login? How do I prevent passwords being transmitted in plain text?
Is that the same for things like username/password fields for login?yes you need to provide the
name for all input fields for them to show up in the FormDataHow do I prevent passwords being transmitted in plain text?requests are encrypted (https), so passwords can be transmitted in plain text and there's nothing wrong. just remember to not save the password in plain text in your database
Oak apple gall waspOP
wonderful 🙂 Thank you so much!
That's all, appreciate the help greatly! Hope you have a wonderful evening
good day for you too