I have the following setup in my +page.server.js:
export const actions = { createScore: async ({ request }) => { const values = await request.formData(); try { const instagram = values.get('username'); const score = Number(values.get('score')); await prisma.score.create({ data: { score, instagram } }); return { success: true }; } catch (err) { console.error(err); return fail(500, { message: 'Could not create the score.' }); } }};
This runs fine, I see the entry in the database. However, no matter how hard I try, I cannot access 'form' to check for the return of sucess in my front end.
I do the following in page.svelte
<script> export let form; console.log(form);</script>
The console log consistently returns null when the form is run.
Further, the following never renders (telling me I am not missing a state change):
{#if form?.success}<p>It Worked</p>{/if}
Finally, form as follows:
<form action="?/createScore" method="POST"><input type="text" id="score" name="score" /><input type="text" id="username" name="username" /><button type="submit">Submit</button></form>
Am I missing something?