From 6943ca491cb37ab46b90c812ea7e046e898cc8f9 Mon Sep 17 00:00:00 2001 From: WardPearce Date: Wed, 3 Apr 2024 03:15:00 +1300 Subject: [PATCH] Fix popular page being disabled --- materialious/src/routes/+page.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/materialious/src/routes/+page.ts b/materialious/src/routes/+page.ts index b3b31184..bfe7d461 100644 --- a/materialious/src/routes/+page.ts +++ b/materialious/src/routes/+page.ts @@ -1,7 +1,19 @@ -import { getPopular } from '$lib/Api/index.js'; +import { getPopular, getTrending } from '$lib/Api/index.js'; +import { error } from '@sveltejs/kit'; -export async function load({ params }) { +export async function load() { + let popular; + + try { + popular = await getPopular(); + } catch (errorMessage: any) { + if (errorMessage.toString() === 'Error: Administrator has disabled this endpoint.') { + popular = await getTrending(); + } else { + error(500, errorMessage); + } + } return { - popular: await getPopular() + popular: popular }; } \ No newline at end of file