Hello everyone, I am currently facing an issue with validating the response from my server using Axios in VueJS.
axios.post('/login', {
email: this.email,
password: this.password
}).then(response => {
if (response.status == 200) {
$root.$data.auth = true;
} else {
alert('Uh oh');
}
}).catch(e => {
if (e.response.status == 422) {
this.error = "Did you forget your login details?";
} else {
this.error = "Something unexpected happened: " + e.response.status;
}
});
After successful logins, I am receiving this error in the console:
Uncaught (in promise) TypeError: Cannot set property 'status' of undefined
This is confusing for me because according to the Axios documentation, I should be able to access the response status object and use it for conditional statements. Can anyone help clarify this?