-
How do I receive POST data?
Please. export default function Home() {
return (
<form method="post">
<textarea
id="title"
rows={1}
name="title"
/>
<textarea
id="body"
rows={15}
name="body"
/>
<button type="submit">
POST
</button>
</form>
);
}
export const handler: Handlers<> = {
async POST(req, ctx) {
console.log((await req.formData()).get("title"));
console.log((await req.formData()).get("body"));
return new Response("", {
status: 303,
headers: {
Location: "/",
},
});
},
}; |
Beta Was this translation helpful? Give feedback.
Answered by
ru88s
Sep 22, 2022
Replies: 1 comment
-
Self resolved. const formData = await req.formData();
const title = formData.get("title");
const body = formData.get("body"); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ru88s
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Self resolved.