Answer the question
In order to leave comments, you need to log in
How to change data in locale storage Angular?
{id: 3; email: "789456123" firstName: "789456123" lastName: "789456123" phone: "789456123"
token: "fake-jwt-token"} this is how they are saved.
delete like this:
home.component.html
<button type="button" class="btn btn-primary" (click)="deleteUser(user.id)">Delete</button>
deleteUser(id: number) {
this.userService.delete(id).pipe(first()).subscribe(() => {
this.loadAllUsers()
});
}
private loadAllUsers() {
this.userService.getAll().pipe(first()).subscribe(users => {
this.users = users;
});
}
delete(id: number) {
return this.http.delete(`${environment.apiUrl}/users/${id}`);
}
}
Answer the question
In order to leave comments, you need to log in
You get data from local Storage, make changes, delete and write again, by and large, you can not delete it, it will overwrite the data with the same key.
Moreover, why edit authorization data?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question