I'm currently working on a Vue.js app with Laravel but I'm having trouble accessing the component from the object. What steps should I take?
<script>
import axios from 'axios';
export default {
data : function (){
return {
email: '',
password: '',
remember: 'true',
errors: [],
}
},
methods : {
validateemail(mail){
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(mail);
},
attemptlogin(){
this.errorsarray = [];
axios.post('/login', {
email: this.email,
password: this.password,
remember : this.remember
}).then(function (response) {
location.reload();
}).catch(function (error) {
var code = error.response.status;
console.log(this.email);
if(code == 422){
this.errors.push("Incorrect information");
}else{
console.log('no');
this.errors.push('Internal server error please try again later')
}
}).then(function () {
console.log('here');
});
},
},
computed : {
isValidInput() {
return this.validateemail(this.email) && this.password;
}
}
}
Additionally, I keep encountering the following error:
Uncaught (in promise) TypeError: Cannot read property 'email' of undefined
I'm uncertain of the reason behind this error. Any assistance would be greatly appreciated. Thank you in advance.