In my Angular project, I have been storing user details in the localStorage under the name 'currentUser'. Everything was working perfectly until recently when an error started to show up.
https://i.sstatic.net/TNuMm.png
The error seems to be originating from the constructor of my code.
constructor(private http: HttpClient) {
this.currentUserSubject = new BehaviorSubject<User>(JSON.parse(localStorage.getItem('currentUser')));
this.currentUser = this.currentUserSubject.asObservable();
}
I made some recent changes by adding roles to the user object.
export class User {
userid: number;
username: string;
password: string;
roles: string[];
}