user signup

This commit is contained in:
2026-03-19 00:03:54 +00:00
parent 7b9c212c0e
commit 00d9d4023c
3 changed files with 23 additions and 13 deletions

View File

@@ -6,14 +6,22 @@ const pass = ref<string>("");
function login(e: SubmitEvent) {
e.preventDefault();
console.log(`${email.value} ${pass.value}`);
fetch("http://localhost:3000/login", {
method: "POST",
body: JSON.stringify({ email: email.value, pass: pass.value}),
body: JSON.stringify({ email: email.value, pass: pass.value }),
headers: new Headers({'content-type': 'application/json'})
});
}
function signup(e: Event) {
e.preventDefault();
fetch("http://localhost:3000/createUser", {
method: "POST",
body: JSON.stringify({ email: email.value, pass: pass.value, name: email.value.split("@")[0] }),
headers: new Headers({'content-type': 'application/json'})
});
}
</script>
<template>
@@ -23,6 +31,6 @@ function login(e: SubmitEvent) {
<label for="pass">Password</label> <br>
<input type="password" id="pass" v-model="pass"/> <br>
<button type="submit">Sign in</button> <br>
<button type="button">Sign up</button>
<button type="button" @click="signup">Sign up</button>
</form>
</template>