In my React application, I am using a callback to perform a delete action against an API using the axios library:
deleteBook(selectedBook) {
return this.setState({selectedBook:selectedBook})
axios.delete(this.apiBooks + '/' + this.selectedBook.id)
.then((res) => {
console.log(res)
})
}
I get an error message in the console: "Unreachable code". I think my syntax it's wrong. I would like to perform 2 actions:
1) Setting the state of selectedBook.
2) Deleting the book item using the Axios library delete method.