I keep getting a string.split
error and its because ionics storage now returns a promise. How can I return the token and use it? When I log token
this is what i get
token= t {__zone_symbol__state: null, __zone_symbol__value: Array(0)} __zone_symbol__state:true __zone_symbol__value:"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIzMjkiLCJpc3MiOiJodHRwOlwvXC9wcm9qZWN0cy5zdGFybGluZXdpbmRvd3MuY29tXC9yZWZyZXNoIiwiaWF0IjoxNTAxMTY
public scheduleRefresh() {
let source = this.authHttp.tokenStream.flatMap(
token => {
console.log("token=", token);
let jwtIat = this.jwtHelper.decodeToken(token).iat;
let jwtExp = this.jwtHelper.decodeToken(token).exp;
let iat = new Date(0);
let exp = new Date(0);
let delay = (exp.setUTCSeconds(jwtExp) - iat.setUTCSeconds(jwtIat));
return Observable.interval(delay);
});
this.refreshSubscription = source.subscribe(() => {
this.refresh().subscribe((res) => console.log('-> Refreshed...'),
(error) => console.log('Refresh error: ' + JSON.stringify(error)))
});
}
}