我试图通过以下方法调用API之前先在线检查设备
1. If connectivity call api.
2. If no connectivity just show alert.
在这里可以帮忙
getArea() {
this.loading = this.loadingCtrl.create({
content: "loading..."
});
this.loading.present();
this.userID = "jmzw";
return this.http
.post(OMWConstants._postsURL + "Areas", 'userID="' + this.userID + '"', {
headers: this.getPostAPIHeader()
}
).toPromise().then(data => {
this.saveArea(data);
this.loading.dismiss();
return data;
}).catch(error => {
this.loading.dismiss();
this.handleError(error);
});
}