i would like to have some help about using Ionic LoadingController while having multiple http calls which are processed in an async function.
Firstly, this is my async function with promises
LoadDatafromUrls(urLs) {
return new Promise((resolve, reject) => {
let loader = this.loadingCtrl.create({
content: 'Info retrieving',
});
var urlCalls = [];
urLs.forEach((entry: any) => {
loader.present().then(()=>{
this.http.get(entry.url).map((response : Response)=>{
console.log(response.json());
urlCalls.push(response.json());
}).subscribe(()=>{
console.log("subscribe");
loader.dismiss();
});
})
})
Promise.resolve(urlCalls).then((res)=>{
console.log(res);
resolve(res);
},
(res)=>{
reject(res);
})
//return Promise;
})
}
Secondly, this is the way i call the above function.
RequestObject.LoadDatafromUrls(urLs).then((results)=>{
console.log(results);
},
(errors)=>{
console.log(errors);
})
In this method, i am having the error message below :
Error message: “Uncaught (in promise): removeView was not found” .
Moreover, it does not work in the way i am expecting.
I am really open for compeletely new methods, new ways. Please share if i can have any better implementation.