this
within a standard function is usually determined by how it's called, not where the function was created. So this
in the callback function here is not the same as this
outside it:
getdata(){
axios.get('/getactions')
.then(function (data) {
console.log(data.data);
this.setState({
status:data
})
})
}
Arrow functions, however, close over the this
of their context, so:
getdata(){
axios.get('/getactions')
.then(data => { // <== Change is here
console.log(data.data);
this.setState({
status:data
})
})
}