Closed RoWEN-FCUB closed 3 years ago
Hi, this code work for me
let result;
this.authService.onTokenChange().subscribe((token: NbAuthJWTToken) => {
if (token.isValid()) {
result = token.getPayload()['role'];
} else {
result = 'guest';
}
});
return observableOf(result);
Thath gave me this error:
Cannot find name 'observableOf'. Did you mean 'Observable'?
And if I use return Observable.of(result);
instead it shows ERROR TypeError: an.Observable is undefined and does not work.
Solved.
getRole(): Observable<string> {
let result;
this.authService.onTokenChange().subscribe((token: NbAuthJWTToken) => {
if (token.isValid()) {
result = token.getPayload()['role'];
} else {
result = 'guest';
}
});
return of(result);
}
Now it's working again.
This is my role.provider copied from documentation:
When I use ng serve it works fine, but when change to ng build --prod I get this error:
this is my package.json :