crea los ficheros donde tiene que funcionar el login

pull/16/head
Borja Robert 2 years ago
parent 43f2fc7809
commit 493bd9b976

@ -1,7 +1,8 @@
/**
*
* @param {*} form
* @returns {Promise<*>}
* @async
* @function send
* @param {HTMLFormElement} form
* @returns {Promise<JSON>}
*/
export const send = async (form) => {
const response = await fetch(form.action, {

@ -0,0 +1,38 @@
import { error } from '@sveltejs/kit';
/** @type {import('./$types').PageServerLoad} */
export const load = async ({ locals }) => {
throw error(404, "error");
};
/** @type {import('./$types').Actions} */
export const actions = {
add: async ({ request, locals }) => {
const form = await request.formData();
await api('POST', `todos/${locals.userid}`, {
text: form.get('text')
});
},
edit: async ({ request, locals }) => {
const form = await request.formData();
await api('PATCH', `todos/${locals.userid}/${form.get('uid')}`, {
text: form.get('text')
});
},
toggle: async ({ request, locals }) => {
const form = await request.formData();
await api('PATCH', `todos/${locals.userid}/${form.get('uid')}`, {
done: !!form.get('done')
});
},
delete: async ({ request, locals }) => {
const form = await request.formData();
await api('DELETE', `todos/${locals.userid}/${form.get('uid')}`);
}
};

@ -0,0 +1,3 @@
<script>
export let data;
</script>
Loading…
Cancel
Save