Shares Menu nearly feature complete

This commit is contained in:
Mawoka
2023-05-24 19:00:30 +02:00
parent 4b8358176b
commit d5cb5b1ff5
9 changed files with 167 additions and 19 deletions
+8 -2
View File
@@ -10,12 +10,18 @@ import type { Data } from '$lib/quiztivity/types';
export const load = (async ({ url, fetch }) => {
const id = url.searchParams.get('id');
const share = url.searchParams.get('share') === 'true';
if (!id) {
throw error(400, 'id missing');
}
const resp = await fetch(`/api/v1/quiztivity/${id}`);
let resp: Response;
if (share) {
resp = await fetch(`/api/v1/quiztivity/shares/${id}`);
} else {
resp = await fetch(`/api/v1/quiztivity/${id}`);
}
if (!resp.ok) {
throw error(404, 'quiztivity not found');
throw error(resp.status);
}
const data: Data = await resp.json();
return {