fixed error handling
This commit is contained in:
parent
3a62d327ad
commit
d585ea3b25
|
@ -10,7 +10,7 @@ export async function getIncidents(): Promise<Incident[]> {
|
|||
let response: Response = await fetch('https://api-nws.nickorlow.com/incidents');
|
||||
try {
|
||||
let incidents: Incident[] = await response.json();
|
||||
if(incidents === null || incidents === undefined) return [];
|
||||
if(incidents === null || incidents === undefined || !Array.isArray(incidents)) return [];
|
||||
return incidents;
|
||||
} catch (e) {
|
||||
return [];
|
||||
|
|
Loading…
Reference in a new issue