I have a crud app to manage students, I want to refresh the student listing whenever I delete a student. But when I am calling the refresh function in the delete function it is throwing an error that my refresh function is not a function. Below is the code of both functions:
deleteStudent(studentId) {
axios.delete('http://localhost:4000/students/delete-student/' + studentId)
.then((res) => {
console.log('Student successfully deleted!')
this.loadStudents()
})
.catch((error) => {
console.log(error)
})
}
loadStudents() {
axios.get('http://localhost:4000/students/')
.then(res => {
this.setState({
students: res.data
});
})
.catch((error) => {
console.log(error);
})
}
Prior thanks for any help!