error handling in auth

This commit is contained in:
realaravinth
2021-06-28 23:03:15 +05:30
parent d298ef4719
commit c581d8d0a3
12 changed files with 51 additions and 15 deletions

View File

@@ -24,6 +24,7 @@ import userExists from './userExists';
import emailExists from './emailExists';
import getFormUrl from '../../../utils/getFormUrl';
import registerShowPassword from '../../../components/showPassword';
import createError from '../../../components/error/index';
//import '../forms.scss';
@@ -72,11 +73,10 @@ const registerUser = async (e: Event) => {
const res = await fetch(formUrl, genJsonPayload(payload));
if (res.ok) {
alert('success');
window.location.assign(VIEWS.loginUser);
} else {
const err = await res.json();
alert(`error: ${err.error}`);
createError(err.error);
}
};