Add proper catch for fetch errors
This commit is contained in:
parent
562c31c947
commit
2fbf607707
@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user