Fix error handling undefined configuration user/clinics
This commit is contained in:
@@ -2,7 +2,12 @@ import { get_api_appointments } from '$lib/backend.js';
|
||||
|
||||
/** @type {import('./$types').PageLoad} */
|
||||
export async function load({ params, fetch }) {
|
||||
let clinics = await (await fetch('/api/config/user/clinics')).json();
|
||||
let clinics = [];
|
||||
try {
|
||||
clinics = await (await fetch('/api/config/user/clinics')).json();
|
||||
} catch(ex) {
|
||||
console.error(ex, ex.stack);
|
||||
}
|
||||
let appointments = await get_api_appointments({ fetch, clinics, date: 'T' });
|
||||
appointments.sort((a, b) => a.time_scheduled < b.time_scheduled ? -1 : a.time_scheduled > b.time_scheduled ? 1 : 0);
|
||||
return {
|
||||
|
Reference in New Issue
Block a user