I have a small PHP API that handles basic user CRUD.
Also I am trying out React frontend where I make api calls using axios.
For some reason oftentimes api call does not get executed. For example I have this method:
delete = async (id: number) => {
if (window.confirm('Are you sure you want to delete this user?')) {
await axios.delete(`users/${id}`);
this.setState({
users: this.state.users.filter((u:User) => u.id !== id)
})
}
}
that is called like this:
<a href="" className="btn btn-sm btn-outline-secondary"
onClick={() =>this.delete(user.id)}>Delete</a>
The user is not being deleted all. However in Postman I can delete it. The API works fine.
I am a bit lost, why could this be happening?
The full file is : here
Other methods do work except delete.
I am new to React and kinda lost here.