In my attempt to create a simple app, I encountered an issue when trying to delete a user by clicking on the delete button.
When attempting to run the server, I received an error related to the then
method in the deleteUser()
component:
deleteUser(user: User, event: any) {
event.stopPropagation();
this.userService
.deleteUser(user)
.then(res => {
this.httpUsers = this.httpUsers.filter(h => h !== user);
if (this.selectedUser === user) { this.selectedUser = null; }
})
.catch(error => this.error = error);
}
The service looks like this:
deleteUser(user: User) {
console.log('Deleting user');
}
The error message reads:
app/users.component.ts(46,8): error TS2339: Property 'then' does not exist on type 'void'.
The error occurs on line 46 with .then(res => {
After researching online, I came across this question and attempted to remove void from the deleteUser function, but it did not resolve the issue.
Can anyone provide insight into what I might be doing wrong?