While working on adding a user login feature in Angular-13, I have the following model:
export interface IUser {
email: string;
token: string;
}
Service:
export class AccountService {
baseUrl = environment.apiUrl;
private currentUserSource = new ReplaySubject<IUser>(1);
currentUser$ = this.currentUserSource.asObservable();
constructor(private http: HttpClient, private router: Router) { }
login(values: any) {
return this.http.post(this.baseUrl + 'account/login', values).pipe(
map((user: IUser) => {
if (user) {
localStorage.setItem('token', user.token);
this.currentUserSource.next(user);
}
})
);
}
}
Encountered this error when trying to implement it:
Argument of type 'OperatorFunction<IUser, void>' is not assignable to parameter of type 'OperatorFunction<Object, void>'
This specific line caused the error:
map((user: IUser) => {
Looking for a workaround to fix this issue.
Appreciate any help provided.