I'm using SvelteKit and I've a form on my page. As I need to manipulate the data before it is sent, I cannot use the SvelteKit's default behaviour of form submission (using action
attribute).
So, according to this part of the documentation, I used a simple event listener and then the fetch
function :
async function handleSubmit(e:Event) { const formData = new FormData(e.target as HTMLFormElement); // ... doing some stuff here const res = await fetch("?/login", { /* plenty of stuff there */ });}
So the action named "login" in ./+page.server.ts
will be executed.
I have a simple question: what path do I write (in fetch
) if I want the default action to be executed, knowing that the current page is in a slug.
Do I write fetch("?/")
? (doesn't work)
Do I write fetch("?"
) ? (doesn't work)
Obviously I could just name it and problem solved. I'm just wondering if there is a solution and if someone has ever thought about this.