I'm trying to push to /home if status==200 ok but it's giving me an error.
handleSubmit = (e) => {
e.preventDefault();
const form = this.props.form;
const { password, username } = this.state;
let data = new FormData(); // creates a new FormData object
data.append('username', form.getFieldValue('username'));
data.append('password', form.getFieldValue('password'));
axios.post('http://127.0.0.1:8000/user/login/', data)
.then(res=>console.log(res))
.then(data => { if(data.status == 200){ history.push('/home');}})
.catch(err=>console.log(err))
};
It renders this:
{data: {…}, status: 200, statusText: "OK", headers: {…}, config: {…}, …}
TypeError: Cannot read property 'status' of undefined