-
Couldn't load subscription status.
- Fork 477
Description
I am using Ionic 2 with a custom Store provider to get/set token data using the native SecureStorage library with a LocalStorage fallback. However, when I attempt to use said store provider to get the token, then return the token from the promise, it appears that the tokenGetter does not wait for the promise to be completed before attempting to process the token.
ionicBootstrap( MyFancyApp, [
Store,
HTTP_PROVIDERS,
AUTH_PROVIDERS,
provide( AuthHttp, {
useFactory: ( http, store ) => {
return new AuthHttp( new AuthConfig({
headerName: 'Authorization',
headerPrefix: 'Bearer',
tokenName: '',
tokenGetter: ( () => {
store.get('bearer').then( token => {
console.log( token );
return token;
});
}),
globalHeaders: [{'Content-Type':'application/json'}]
}), http );
},
deps: [ Http, Store ]
})
]);When I attempt to use AuthHttp to make a request, I get the following feedback in the console:

It appears that the error is thrown by AuthHttp before the token is logged to the console, which is what leads me to think it isn't waiting for the promise. Any ideas? I'm pretty new to Angular 2 so I could just be doing this wrong. Thanks!