I have an interface :
export interface Me {
id: number;
email: string;
}
I have my component :
export class MyComponent implements OnInit {
me: Me;
ngOnInit() {
this.me = JSON.parse(localStorage.getItem('me'));
console.log(this.me);
}
}
And in console I have :
{
"id": 11,
"lastname": "lastname",
"firstname": "firstname",
"email": "@mail.ru",
"enable": true
}
Normally I should have only the fields : id, email
. But I get the whole response from /me
api call. Have you an idea how I can cast the interface to the reponse from localStorage ? Thx in advance.