From 3a62d327adde1927d9218bf48b6874d886557125 Mon Sep 17 00:00:00 2001 From: Nicholas Orlowsky Date: Mon, 12 Dec 2022 02:34:57 -0600 Subject: [PATCH] Update calls.ts --- src/nws-api/calls.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/nws-api/calls.ts b/src/nws-api/calls.ts index 93164a8..89eb763 100644 --- a/src/nws-api/calls.ts +++ b/src/nws-api/calls.ts @@ -8,7 +8,12 @@ export async function getUptime(): Promise { export async function getIncidents(): Promise { 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 []; + } }