-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
HTML FormData docs #735
Comments
Is this still an issue? I see code that should handle it:
|
@benmccann I'll update my repro repo to see if the issue still occurs. Will update. |
Updated https://github.com/didier/kit-formdata/blob/latest/src/routes/login.js. So you can't grab the data directly from the request, but you can use the export async function post({ body }) {
console.log(body) // ReadOnlyFormData {}
console.log(body.get('email')) // 'your@email.com'
} I think as it stands right now, this may be more of a documentation issue than a functionality issue. |
Just ran into this myself. Here's what I initially tried in my export async function post(req) {
const username = req.body?.username
const password = req.body?.password
if (!username || !password) {
return {
status: 400,
body: { error: 'syntax_error', description: 'POST body should include username and password fields' }
}
}
// Login logic goes here
} Changing it to Might be a good idea to expand the documention with an example of parsing a POST body. |
I sent a PR for this: #2095 I didn't add an example, but added a new sub-heading, so hopefully that will make it easier to notice |
Describe the bug
When submitting a form using the POST method, no data is picked up by the request body in the endpoint. When sending the same data using something like Curl, Postman, Insomnia or any other HTTP tool, the JSON body is parsed correctly.
Logs
None
To Reproduce
I've created a repo: https://github.com/didier/kit-formdata.
Init options were no typescript, css for styling and no linting/formatting.
Expected behavior
I would expect an endpoint receiving a POST request from a form to handle the form data in the body object correctly, as per the docs.
Information about your SvelteKit Installation:
Brave Browser: 89.1.22.70
I'm using the node adapter, but since this issue happens in development too, I'm guessing this happens to other adapters as well.
Severity
High — I want to be able to progressively enhance my application, so submitting a form without JS should work too. And the docs say this is implemented.
The text was updated successfully, but these errors were encountered: