Есть такая форма:
<form @submit.prevent="atEmailLogin" class="login-form">
<div class="login-form__title">
Вход в личный кабинет агента
</div>
<p class="main_errors">
{{ auth_errors }}
</p>
<label class="login-form__label" :class="{ error: loginForm.errors.login || auth_errors }">
<span>Логин</span>
<input v-model="loginForm.login" type="text" />
<p class="errors" v-if="loginForm.errors.login">
<i class="el-icon-close"></i>
{{ loginForm.errors.login }}
</p>
</label>
<label class="login-form__label" :class="{ error: loginForm.errors.password || auth_errors}">
<span>Пароль</span>
<input v-model="loginForm.password" type="password" />
<span v-if="errors.password && errors.password.length" class="error-text">Неверный пароль</span>
<p class="errors" v-if="loginForm.errors.password">
<i class="el-icon-close"></i>
{{ loginForm.errors.password }}
</p>
</label>
<button class="submit-btn" type="submit">Войти</button>
</form>
atEmailLogin(event) {
if(this.loginForm.login && this.loginForm.password) {
this.$store.dispatch('atEmailLogin', this.loginForm)
// .then( response => )
// .catch(error => (this.errors = error));
}
this.loginForm.errors.login = '',
this.loginForm.errors.password = '';
if(!this.loginForm.login) {
this.loginForm.errors.login = 'Неверный логин';
}
if(!this.loginForm.password) {
this.loginForm.errors.password = 'Неверный пароль';
}
}
Выдает ошибку
unknown action type: atEmailLogin
.
atEmailLogin({ commit }, formData) {
console.log('123')
return API.post("/login", formData)
.then(response => {
if (response && response.status === 201) {
commit(SET_AUTH_STATE, response.data);
return response.data;
}
commit(CLEAR_ERROR);
if (response.data.success) {
console.log('success')
router.push('/')
} else {
commit(SET_ERRORS, response.data.error);
}
})
.catch(error => {
return Promise.reject(error.response.data.errors);
});
},