I have login operations in my project here is when ı successfully login swal alert working but my problem is when i login wrong it doesn't working. You can see code below .How can i fix it? Thanks in advance!
script
// Send login request
await store.dispatch(Actions.LOGIN, data);
const [errorName] = Object.keys(store.getters.getErrors);
const error = store.getters.getErrors[errorName];
if (!error) {
Swal.fire({
title: i18n.t("swal.success.success"),
text: i18n.t("swal.success.title"),
icon: "success",
buttonsStyling: false,
confirmButtonText: i18n.t("swal.success.buttonText"),
customClass: {
confirmButton: "btn fw-semobold btn-light-primary",
},
}).then(function () {
// Go to page after successfully login
router.push({ name: "projects" });
});
} else {
Swal.fire({
title: i18n.t("swal.error.error"),
text: i18n.t("swal.error.title"),
icon: "error",
buttonsStyling: false,
confirmButtonText: i18n.t("swal.error.buttonText"),
customClass: {
confirmButton: "btn fw-semobold btn-light-danger",
},
});
}
Auth
@Action
async [Actions.LOGIN](user) {
try {
const response = await Auth.signIn(user);
this.context.commit(Mutations.SET_TOKEN, response.data);
this.context.dispatch(Actions.AXIOS_INTERCEPTOR);
return Promise.resolve(response);
} catch (error) {
return Promise.reject(error);
}
}