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 { error } from '@sveltejs/kit';
|
||||||
|
import { getAllPostersFromDB } from '$lib/db/utils';
|
||||||
|
|
||||||
/** @type {import('./$types').PageServerLoad} */
|
/** @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");
|
throw error(404, "error");
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @type {import('./$types').Actions} */
|
// /** @type {import('./$types').Actions} */
|
||||||
export const actions = {
|
// export const actions = {
|
||||||
add: async ({ request, locals }) => {
|
// add: async ({ request, locals }) => {
|
||||||
const form = await request.formData();
|
// const form = await request.formData();
|
||||||
|
|
||||||
await api('POST', `todos/${locals.userid}`, {
|
// await api('POST', `todos/${locals.userid}`, {
|
||||||
text: form.get('text')
|
// text: form.get('text')
|
||||||
});
|
// });
|
||||||
},
|
// },
|
||||||
edit: async ({ request, locals }) => {
|
// edit: async ({ request, locals }) => {
|
||||||
const form = await request.formData();
|
// const form = await request.formData();
|
||||||
|
|
||||||
await api('PATCH', `todos/${locals.userid}/${form.get('uid')}`, {
|
// await api('PATCH', `todos/${locals.userid}/${form.get('uid')}`, {
|
||||||
text: form.get('text')
|
// text: form.get('text')
|
||||||
});
|
// });
|
||||||
},
|
// },
|
||||||
toggle: async ({ request, locals }) => {
|
// toggle: async ({ request, locals }) => {
|
||||||
const form = await request.formData();
|
// const form = await request.formData();
|
||||||
|
|
||||||
await api('PATCH', `todos/${locals.userid}/${form.get('uid')}`, {
|
// await api('PATCH', `todos/${locals.userid}/${form.get('uid')}`, {
|
||||||
done: !!form.get('done')
|
// done: !!form.get('done')
|
||||||
});
|
// });
|
||||||
},
|
// },
|
||||||
delete: async ({ request, locals }) => {
|
// delete: async ({ request, locals }) => {
|
||||||
const form = await request.formData();
|
// const form = await request.formData();
|
||||||
|
|
||||||
await api('DELETE', `todos/${locals.userid}/${form.get('uid')}`);
|
// await api('DELETE', `todos/${locals.userid}/${form.get('uid')}`);
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
<script>
|
<script>
|
||||||
export let data;
|
export let data;
|
||||||
|
console.log(data);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<h1>Test</h1>
|
||||||
|
Loading…
Reference in New Issue