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