Answer the question
In order to leave comments, you need to log in
Is this a good practice to use Vuex?
Is it possible to use Vuex like this?
export const actions = {
async signIn(ctx, credentials) {
await this.$auth.loginWith("local", {
data: credentials
});
},
async signUp(ctx, user) {
return await this.$axios.$post("auth/sign-up", user);
}
};
this.$store.dispatch("signUp", this.user).then(res => {
if (res.errors) {
this.errors = res.errors;
} else {
this.$store.dispatch("signIn", {
email: this.user.email,
password: this.user.password
});
}
this.loading = false;
});
Answer the question
In order to leave comments, you need to log in
Authorization data is needed for routing, at least, plus every time you access the server, you must send a token, which also feels great
in vuex. the server will be processed, now you have a dispatch and this.loading = false at the same time, you can, of course, in the component, but then the code will become more complicated, as for me
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question