I'm trying to add data in LocalStorage through a form. However, it always overrides the value and the key that I had given does not appear (it gets 1).
In this snippet of code it is when it takes the user object (it is an input) and sends to the LocalStorage only the "user.name". It sends the value.
register(user: User) {
this.user = new User;
window.localStorage.setItem('user', user.name);
}
Result in LocalStorage:
Note that the key is not the one I set (user). And consequently, when I make other inserts, with other keys, it replaces the value.