Update calls.ts

This commit is contained in:
Nicholas Orlowsky 2022-12-12 02:34:57 -06:00 committed by GitHub
parent 8456552f5a
commit 3a62d327ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,7 +8,12 @@ export async function getUptime(): Promise<UptimeResponse> {
export async function getIncidents(): Promise<Incident[]> {
let response: Response = await fetch('https://api-nws.nickorlow.com/incidents');
let incidents: Incident[] = await response.json();
return incidents;
try {
let incidents: Incident[] = await response.json();
if(incidents === null || incidents === undefined) return [];
return incidents;
} catch (e) {
return [];
}
}