From bdc9ee0f61025d63f9f324025db6f379be834336 Mon Sep 17 00:00:00 2001 From: secondl1ght Date: Thu, 21 Dec 2023 20:10:15 -0700 Subject: [PATCH] refactor 404 handlers --- src/routes/community/[area]/+page.svelte | 68 +++++++++++++----------- src/routes/merchant/[id]/+page.svelte | 8 +-- src/routes/merchant/[id]/+page.ts | 2 +- src/routes/tagger/[id]/+page.svelte | 62 ++++++++++----------- src/routes/tagger/[id]/+page.ts | 15 +++--- 5 files changed, 79 insertions(+), 76 deletions(-) diff --git a/src/routes/community/[area]/+page.svelte b/src/routes/community/[area]/+page.svelte index 0e8521a6..9768127f 100644 --- a/src/routes/community/[area]/+page.svelte +++ b/src/routes/community/[area]/+page.svelte @@ -3,7 +3,6 @@ import { browser } from '$app/environment'; import { goto } from '$app/navigation'; - import { page } from '$app/stores'; import { Footer, Header, @@ -851,9 +850,9 @@ - {$page.data.name} - BTC Map Community + {name ? name + ' - ' : ''}BTC Map Community - + {#if lightning && lightning.type === 'address'} @@ -889,7 +888,7 @@
{/if}

- {name} + {name || 'BTC Map Community'}

{#if org} @@ -919,26 +918,28 @@ {:else} {#if dataInitialized} @@ -980,7 +981,7 @@

- {name} Map + {name || 'BTC Map Community'} Map

diff --git a/src/routes/tagger/[id]/+page.ts b/src/routes/tagger/[id]/+page.ts index cf4f5ee2..ba560ff3 100644 --- a/src/routes/tagger/[id]/+page.ts +++ b/src/routes/tagger/[id]/+page.ts @@ -7,14 +7,15 @@ axiosRetry(axios, { retries: 3, retryDelay: axiosRetry.exponentialDelay }); // @ts-expect-error export async function load({ params }) { const { id } = params; + try { + const response = await axios.get(`https://api.btcmap.org/v2/users/${id}`); - const response = await axios.get(`https://api.btcmap.org/v2/users/${id}`); + const data = response.data; - const data = response.data; - - if (data) { - return { user: data.id, username: data['osm_json']['display_name'] }; + if (data) { + return { user: data.id, username: data['osm_json']['display_name'] }; + } + } catch (err) { + error(404, 'User Not Found'); } - - error(404, 'User Not Found'); }