fixed error handling

This commit is contained in:
Nicholas Orlowsky 2022-12-12 09:43:40 -06:00
parent 3a62d327ad
commit d585ea3b25
No known key found for this signature in database
GPG key ID: 3845F78A73B14100

View file

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