I am trying to set state after axios calls. Inside then clause I have been trying to set state with this.setState({...})
but this is undefined here.
Why console.log(this)
is printing 'undefined' in console?
clickButton() {
let data = {
username : document.querySelector('#email').value,
password : document.querySelector('#password').value
};
axios.post('http://127.0.0.1:8000/api/login_check', data, {
headers: {
'Content-Type' : 'application/json',
}
})
.then(res => {
console.log(this)
})
}