You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm taking the Fullstack SvelteKit course and running into a bug at the 2:56:00 mark when trying to create the post Endpoint https://youtu.be/OUzaUJ3gEug?t=10560
import type { RequestHandler } from "@sveltejs/kit";
// this breaks...
export const post: RequestHandler<{}, FormData> = (request) => {
console.log(request.body.get("text"));
}
When submitting the post request from the form, I get the 500 (Internal Server Error) and it appears that a new Breaking PR was merged in 7 days ago from rich that broke it sveltejs/kit#3384
Can anyone recommend a good step-by-step for me to follow to fix?
Je suis le cours Fullstack SvelteKit et je rencontre un bogue à la 2:56:00marque lorsque j'essaie de créer le **post Endpoint ** https://youtu.be/OUzaUJ3gEug?t=10560
import type { RequestHandler } from "@sveltejs/kit";
// this breaks...
export const post: RequestHandler<{}, FormData> = (request) => {
console.log(request.body.get("text"));
}
Lors de la soumission de la demande de publication à partir du formulaire, j'obtiens le 500 (erreur de serveur interne) et il semble qu'un nouveau Breaking PR a été fusionné il y a 7 jours par Rich qui l'a cassé sveltejs/kit#3384
Quelqu'un peut-il me recommander une bonne étape par étape à suivre pour réparer?
This will get you halfway through the tutorial but I'm running into more issues as I get further along. But I'm confident in making it to the end. Still reading through the new SvelteKit docs and seeing how to update code that's changed.
Anyways, give this a try and let me know if it helps.
importtype{RequestHandler}from"@sveltejs/kit";// getexportconstget: RequestHandler=async({ request })=>{return{status: 200,body: "Hello from the API!"}}// postexportconstpost: RequestHandler=async({ request })=>{constformData=awaitrequest.formData();return{body: formData.get('text')asstring}}
Reacted by cirezd, PB, Rozman123Rok, Lucas Balangero, alex, spiceydev, ZeeG, Wooseok Yang and Justin O'Neill
Thank you Huansock, it works! Your answer is the best! It's just now you still need to change the word "post" into uppercase "POST", otherwise it still fails.
Activity
j314h commentedon Jan 27, 2022
hello, did you find a solution?
I'm in the same situation as you.
here is my code
my console.log() returns me a " file{} "
an empty object. the "test" key exists
but it is empty
if you solved your problem i would like some help
thank you for your future response
oneezy commentedon Jan 28, 2022
hey @j314h , I actually did solve it!
This will get you halfway through the tutorial but I'm running into more issues as I get further along. But I'm confident in making it to the end. Still reading through the new SvelteKit docs and seeing how to update code that's changed.
Anyways, give this a try and let me know if it helps.
wooseok-yang-kr commentedon May 22, 2022
hey guys i had same Problem too.
and i fixed it without RequestHandler.
for that i read BodyParsing in SvelteKit Doc https://kit.svelte.dev/docs/routing#endpoints-body-parsing
Here's my code
zfbxrk518 commentedon Jul 28, 2022
Thank you Huansock, it works! Your answer is the best! It's just now you still need to change the word "post" into uppercase "POST", otherwise it still fails.