I am trying to get 2 values stores in ionic storage , but the value are retrived in async way and request is happening before the values are retrived
Here Auth, url
You have to wait for both promise to get resolved before make request.
First move your storage code to some init method.
public init(){
let promiseList: Promise<any>[] = [];
promiseList.push(
this.storage.get('Auth').then((Auth) => {
console.log('Retrived Auth is', Auth);
this.Auth = Auth;
} ));
promiseList.push(
this.storage.get('url').then((url) => {
console.log('Retrived url is', url);
this.url = url;
} ));
return Promise.all(promiseList);
}
Now call init method before getSesonList as followed:
this.sessionService.init().then((values)=>{
this.sessionService.getSeasonList();
});
this will make sure that the getSeasonList method will be called after both storage promises get resolved.
Obviously you should put some error handling code but its upon you.