changed functions for nuxt-friendly version
This commit is contained in:
@@ -39,20 +39,17 @@ const schema = z.object({
|
||||
type Schema = z.output<typeof schema>
|
||||
|
||||
function onSubmit(payload: FormSubmitEvent<Schema>) {
|
||||
return fetch(base_url + "/login", {
|
||||
return $fetch("/login", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type" : "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
body: {
|
||||
email: payload.data.email,
|
||||
password: payload.data.password,
|
||||
remember: payload.data.remember || false
|
||||
})
|
||||
}).then((response) => {
|
||||
if (response.ok)
|
||||
window.location.href = "/";
|
||||
else if (response.status == 401) {
|
||||
}
|
||||
}).then((r) => {
|
||||
reloadNuxtApp({path: "/"});
|
||||
}).catch((err) => {
|
||||
if(err.data.statusCode == 401) {
|
||||
wrong_login.value = true;
|
||||
// show for 5 seconds
|
||||
setTimeout(() => wrong_login.value = false, 5000);
|
||||
|
||||
Reference in New Issue
Block a user