include axios and show toasts
This commit is contained in:
parent
712af41c28
commit
5b2252d6bd
5 changed files with 69 additions and 19 deletions
|
@ -6,6 +6,7 @@
|
|||
{{template "head" .}}
|
||||
</head>
|
||||
<body>
|
||||
{{template "toasts" .}}
|
||||
{{template "navbar" .}}
|
||||
|
||||
<div class="position-absolute top-50 start-50 translate-middle">
|
||||
|
@ -18,13 +19,15 @@
|
|||
{{template "scripts" .}}
|
||||
{{template "formScripts" .}}
|
||||
<script>
|
||||
async function submitForm(formData) {
|
||||
const response = await fetch("/auth/register", {method: 'POST', body: formData, redirect: 'follow'});
|
||||
if (response.ok) {
|
||||
redirect("/");
|
||||
} else {
|
||||
redirect("/view/register");
|
||||
}
|
||||
function submitForm(formData) {
|
||||
axios({method: 'POST', url: '/auth/register', data: formData})
|
||||
.then((response) => {
|
||||
showSuccessToast(response.data.message);
|
||||
redirect("/login");
|
||||
})
|
||||
.catch((err) => {
|
||||
showErrorToast(err.message);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
|
Reference in a new issue