StaffLDB-Minify #1
@ -1,8 +1,8 @@
|
|||||||
// Fetches StaffLDB Data, correctly formats DATE fields and returns the data
|
// Fetches StaffLDB Data, correctly formats DATE fields and returns the data
|
||||||
|
|
||||||
import { getApiUrl } from "$lib/scripts/upstream";
|
import { getApiUrl } from '$lib/scripts/upstream';
|
||||||
import { uuid } from "$lib/stores/uuid";
|
import { uuid } from '$lib/stores/uuid';
|
||||||
import type { ApiResponse, StaffLdb } from "@owlboard/ts-types";
|
import type { ApiResponse, StaffLdb } from '@owlboard/ts-types';
|
||||||
|
|
||||||
// Fetch StaffLDB Data, and returns the data after hydration (convert date types etc.)
|
// Fetch StaffLDB Data, and returns the data after hydration (convert date types etc.)
|
||||||
export async function fetchStaffLdb(station: string): Promise<ApiResponse<StaffLdb>> {
|
export async function fetchStaffLdb(station: string): Promise<ApiResponse<StaffLdb>> {
|
||||||
@ -16,13 +16,13 @@ export async function fetchStaffLdb(station: string): Promise<ApiResponse<StaffL
|
|||||||
const fetchOpts = {
|
const fetchOpts = {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
uuid: uuid_value,
|
uuid: uuid_value
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
const res = await fetch(url, fetchOpts)
|
const res = await fetch(url, fetchOpts);
|
||||||
unsubscribe();
|
unsubscribe();
|
||||||
const resJs = await res.json()
|
const resJs = await res.json();
|
||||||
return parseFormat(JSON.stringify(resJs))
|
return parseFormat(JSON.stringify(resJs));
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseFormat(jsonString: any): ApiResponse<StaffLdb> {
|
function parseFormat(jsonString: any): ApiResponse<StaffLdb> {
|
||||||
@ -33,6 +33,6 @@ function parseFormat(jsonString: any): ApiResponse<StaffLdb> {
|
|||||||
return new Date(value);
|
return new Date(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return value
|
return value;
|
||||||
});
|
});
|
||||||
}
|
}
|
@ -29,7 +29,7 @@
|
|||||||
title = data.data.locationName;
|
title = data.data.locationName;
|
||||||
return data.data;
|
return data.data;
|
||||||
}
|
}
|
||||||
throw new Error("Unable to Fetch Data")
|
throw new Error('Unable to Fetch Data');
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user