ya es capaz de leer de la db y mandarlo a la web
parent
493bd9b976
commit
5611c2775b
Binary file not shown.
@ -1,38 +1,43 @@
|
||||
import { error } from '@sveltejs/kit';
|
||||
import { getAllPostersFromDB } from '$lib/db/utils';
|
||||
|
||||
/** @type {import('./$types').PageServerLoad} */
|
||||
export const load = async ({ locals }) => {
|
||||
|
||||
|
||||
export const load = async () => {
|
||||
const posters = getAllPostersFromDB();
|
||||
if (posters !== undefined) {
|
||||
return {
|
||||
posters: posters
|
||||
}
|
||||
}
|
||||
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')}`);
|
||||
}
|
||||
};
|
||||
// /** @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')}`);
|
||||
// }
|
||||
// };
|
||||
|
@ -1,3 +1,6 @@
|
||||
<script>
|
||||
export let data;
|
||||
console.log(data);
|
||||
</script>
|
||||
|
||||
<h1>Test</h1>
|
||||
|
Loading…
Reference in New Issue