I am getting this error:
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'setState')
and this is my code:
class Table extends Component {
constructor (props) {
super(props);
this.state = {
employees: [],
}
}
componentDidMount() {
this.getEmployeeList();
}
getEmployeeList = () => {
axios.get("employee/list")
.then(function(response) {
this.setState({
employees: response.data,
});
});
console.log(this.state.employees)
}
// Remaining codes
}