I am attempting to trigger an action once a promise request has been resolved, but I'm having trouble figuring out how to achieve this.
After doing some research, I learned that Ionic2 storage.get() returns a promise, and I would like to make an HTTP request that returns an observable.
Here is what I have attempted so far:
constructor(storage:Storage){}
getAll():Observable<any>{
this.storage.get("token")
.then(res=>{ //perform the get request after value of token is found
if(res){
return this._http.get(this.companiesurl+"?access-token="+res)//attach token
.map(res=>res.json().data)
}
}
}
The above function is invoked in a constructor.
this.chojeService.getAll().subscribe(response => {
this.users = response
},