From 2fbf6077075036e5c4343410bc0d0f3852e783bd Mon Sep 17 00:00:00 2001 From: garrettmills Date: Wed, 28 Oct 2020 11:06:17 -0500 Subject: [PATCH] Add proper catch for fetch errors --- src/app/service/api.service.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/app/service/api.service.ts b/src/app/service/api.service.ts index c0cd5d6..68485a6 100644 --- a/src/app/service/api.service.ts +++ b/src/app/service/api.service.ts @@ -61,8 +61,13 @@ export class ApiService { } public checkOnline(): Promise { - return fetch(this.statUrl).then(resp => { - return resp && (resp.ok || resp.type === 'opaque'); + return new Promise(res => { + fetch(this.statUrl).then(resp => { + res(resp && (resp.ok || resp.type === 'opaque')); + }).catch(e => { + console.error('Check Online Error', e); + res(false); + }); }); }