...

/

Login Configuration

Login Configuration

Learn how to implement the login functionality with Vuex.

Here, we are going to implement the login functionality using the action from the users module. We will start by defining some variables and methods inside the Login.vue file as shown in the code snippet below:

Press + to interact
<script>
export default {
data: function() {
return {
password: "",
email: "",
errors: []
};
},
methods: {
login() {
this.$store
.dispatch("users/loginUser", {
email: this.email,
password: this.password
})
.then(() => {
this.errors = [];
this.$router.replace({name : "Home"});
})
.catch(err => {
this.errors.push(err);
});
}
}
};
</script>

Binding state variables to

...