80
rated 0 times
[
82]
[
2]
/ answers: 1 / hits: 12795
/ 2 Years ago, sat, march 26, 2022, 12:00:00
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
}
More From » reactjs