Add proper catch for fetch errors
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing

This commit is contained in:
Garrett Mills 2020-10-28 11:06:17 -05:00
parent 562c31c947
commit 2fbf607707
Signed by: garrettmills
GPG Key ID: D2BF5FBA8298F246

View File

@ -61,8 +61,13 @@ export class ApiService {
}
public checkOnline(): Promise<boolean> {
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);
});
});
}