StaffLDB-Minify #1
@ -5,6 +5,10 @@
|
|||||||
|
|
||||||
export let station: string;
|
export let station: string;
|
||||||
export let title: string | undefined = 'Loading...';
|
export let title: string | undefined = 'Loading...';
|
||||||
|
export let error = {
|
||||||
|
state: false,
|
||||||
|
name: 'none',
|
||||||
|
}
|
||||||
|
|
||||||
async function fetchStaffLdb(station: string) {
|
async function fetchStaffLdb(station: string) {
|
||||||
const url = `${getApiUrl()}/api/v2/live/station/${station}/staff`;
|
const url = `${getApiUrl()}/api/v2/live/station/${station}/staff`;
|
||||||
@ -19,9 +23,14 @@
|
|||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
jsonData = await res.json();
|
jsonData = await res.json();
|
||||||
title = jsonData.data?.locationName;
|
title = jsonData.data?.locationName;
|
||||||
|
error.state = false;
|
||||||
} else if (res.status === 401) {
|
} else if (res.status === 401) {
|
||||||
console.log(`Request Status: ${res.status}`);
|
console.log(`Request Status: ${res.status}`);
|
||||||
title = 'Unauthorised';
|
title = 'Unauthorised';
|
||||||
|
error = {
|
||||||
|
state: true,
|
||||||
|
name: 'unauthorized',
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@ -33,3 +42,9 @@
|
|||||||
{:catch}
|
{:catch}
|
||||||
Error Loading
|
Error Loading
|
||||||
{/await}
|
{/await}
|
||||||
|
|
||||||
|
{#if error.state}
|
||||||
|
{#if error.name === 'unauthorized'}
|
||||||
|
<p>Error: {error.name.toLocaleUpperCase()}</p>
|
||||||
|
{/if}
|
||||||
|
{/if}
|
||||||
|
Loading…
Reference in New Issue
Block a user