i have one observable function in my service which i have subscribe but i am getting [object Object] instead of token value
get bearerToken(): Observable<string | null> {
return this.store.select(AuthStatusState.getToken).pipe(
map((token) => {
if (token) {
return token;
} else {
return null;
}
}),
take(1)
);
}
const authToken = this.authService.bearerToken.subscribe();
console.log(authToken);
i want token to be saved in const instead of object
Like this authToken
is a subscription.
const authToken = this.authService.bearerToken.subscribe();
Like this authToken
will be the value emitted by bearerToken
.
let authToken;
this.authService.bearerToken.subscribe( data => authToken = data);
console.log(authToken);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.