angular - How to retrieve token as string from storage (string.split error) -


i keep getting string.split error trying issued @ time using jwthelper jwtheler.decodetoken(token).iat. how can retrieve token as string instead of promise?

this when log token

t {__zone_symbol__state: null, __zone_symbol__value: array(0)} __zone_symbol__state:true __zone_symbol__value:"eyj0exaioijkv1qilcjhbgcioijiuzi1nij9.eyjzdwiioiizmjkilcjpc3mioijodhrwolwvxc9wcm9qzwn0cy5zdgfybgluzxdpbmrvd3muy29txc9yzwzyzxnoiiwiawf0ijoxntaxmty 

refresh function

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)))     });   } } 

app.module.ts

export function getauthhttp(http, storage) {   return new authhttp(new authconfig({     headername: 'authorization',     headerprefix: 'bearer',     nojwterror: true,     globalheaders: [{'accept': 'application/json', 'content-type': 'application/json', 'x-requested-with': 'xmlhttprequest'}],     tokengetter: (() =>   storage.ready().then(() => storage.get('token')))   }), http); } 


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -