I have so confused when handling the data from the server. I have a provider that fetch the data from the server through HTTP. I want to load the data before the page can be loaded. but the data will take a time to reflect on the page. Anyone please guide me to handling data from server
here is my code
workpage.ts
loadWork(){
this.work.loadwrk().then(hw=>{
this.work = work ;
})
ionViewWillEnter(){
this.loadWork();
}
workprovider.ts
loadwrk():Promise<any>{
return new Promise(resolve =>{
this.storage.get('works').then(ow=>{
this.http.get(---url----).subscribe((res)=>{
let resData = res.json();
if(JSON.stringify(ow) !=JSON.stringify(resData)){
console.log('i am new work');
resolve(resData);
}
else{
resolve(ow);
console.log('i am old work');
}
})
})
})
}