I am currently developing a Vue application for the backend and I want to introduce an artificial delay to actions. For example, when I submit a sign in
request, I would like to add a 1-second delay before redirecting to the main application.
This is the submit method within the component:
onSubmit() {
this.loading = true;
this.$store.dispatch('auth/signIn', this.credentials).then(() => {
this.loading = false;
});
}
Here is the signIn method from the action:
async signIn({ commit }, credentials) {
const result = await authService.signIn(credentials);
await commit(AUTHENTICATE, {
authenticated: result
});
}
However, I encountered an issue with the authService method as it returns undefined
. Here's the block of code that is causing the problem:
async signIn(credentials) {
setTimeout(() => {
console.log('credentials', credentials);
return true;
}, 2000);
}
Could someone assist me in resolving this issue?