From 7b50bbe48600b7201968d11f85f535a86f784e14 Mon Sep 17 00:00:00 2001 From: Mawoka Date: Wed, 19 Apr 2023 18:59:48 +0200 Subject: [PATCH] :sparkles: Closes #224 --- frontend/src/routes/explore/+page.svelte | 42 +++++++----------------- frontend/src/routes/explore/+page.ts | 22 +++++++++++++ 2 files changed, 33 insertions(+), 31 deletions(-) create mode 100644 frontend/src/routes/explore/+page.ts diff --git a/frontend/src/routes/explore/+page.svelte b/frontend/src/routes/explore/+page.svelte index 2fef054..b9b70b2 100644 --- a/frontend/src/routes/explore/+page.svelte +++ b/frontend/src/routes/explore/+page.svelte @@ -5,42 +5,22 @@ --> ClassQuiz - Explore -{#await getData()} - - - - -{:then quizzes} -
- {#each quizzes.hits as quiz} - - {/each} -
-{/await} +
+ {#each quizzes.hits as quiz} + + {/each} +
diff --git a/frontend/src/routes/explore/+page.ts b/frontend/src/routes/explore/+page.ts new file mode 100644 index 0000000..3e0ff7b --- /dev/null +++ b/frontend/src/routes/explore/+page.ts @@ -0,0 +1,22 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ +import type { PageLoad } from './$types'; + +export const load = (async ({ fetch }) => { + const response = await fetch('/api/v1/search/', { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + q: '*', + sort: ['created_at:desc'] + }) + }); + return { + results: await response.json() + }; +}) satisfies PageLoad;