diff --git a/frontend/src/lib/components/AdventureLink.svelte b/frontend/src/lib/components/AdventureLink.svelte index 71486ee..b1bb85f 100644 --- a/frontend/src/lib/components/AdventureLink.svelte +++ b/frontend/src/lib/components/AdventureLink.svelte @@ -10,6 +10,8 @@ let adventures: Adventure[] = []; + let isLoading: boolean = true; + export let user: User | null; onMount(async () => { @@ -17,19 +19,16 @@ if (modal) { modal.showModal(); } - let formData = new FormData(); - formData.append('include_collections', 'false'); - let res = await fetch(`/adventures?/all`, { - method: 'POST', - body: formData + let res = await fetch(`/api/adventures/all/?include_collections=false`, { + method: 'GET' }); - const result: ActionResult = deserialize(await res.text()); - console.log(result); + const newAdventures = await res.json(); - if (result.type === 'success' && result.data) { - adventures = result.data.adventures as Adventure[]; + if (res.ok && adventures) { + adventures = newAdventures; } + isLoading = false; }); function close() { @@ -53,11 +52,16 @@
No adventures found that can be linked to this collection.
diff --git a/frontend/src/routes/adventures/[id]/+page.server.ts b/frontend/src/routes/adventures/[id]/+page.server.ts index 8c0a4bc..aa253fb 100644 --- a/frontend/src/routes/adventures/[id]/+page.server.ts +++ b/frontend/src/routes/adventures/[id]/+page.server.ts @@ -146,15 +146,13 @@ export const actions: Actions = { }; } - let trip_id_number: number = parseInt(trip_id as string); - let res = await fetch(`${serverEndpoint}/api/adventures/${event.params.id}/`, { method: 'PATCH', headers: { Cookie: `${event.cookies.get('auth')}`, 'Content-Type': 'application/json' }, - body: JSON.stringify({ collection: trip_id_number }) + body: JSON.stringify({ collection: trip_id }) }); let res2 = await res.json(); console.log(res2); diff --git a/frontend/src/routes/adventures/[id]/+page.svelte b/frontend/src/routes/adventures/[id]/+page.svelte index 240a3c0..0640383 100644 --- a/frontend/src/routes/adventures/[id]/+page.svelte +++ b/frontend/src/routes/adventures/[id]/+page.svelte @@ -171,7 +171,7 @@ {adventure.location}