r
This commit is contained in:
parent
6666025726
commit
d6ac0fd8b4
@ -34,41 +34,6 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script src="./register.js"></script>
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
|
||||||
const btn = document.getElementById("registerBtn")
|
|
||||||
const emailInput = document.getElementById("email")
|
|
||||||
const usernameInput = document.getElementById("username")
|
|
||||||
const passwordInput = document.getElementById("password")
|
|
||||||
|
|
||||||
async function handleRegister() {
|
|
||||||
try {
|
|
||||||
const response = await fetch("https://yggdrasil.azures.fr/register", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json"
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
|
||||||
email: emailInput.value,
|
|
||||||
username: usernameInput.value,
|
|
||||||
password: passwordInput.value
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
const json = await response.json()
|
|
||||||
|
|
||||||
if (json.code !== 200) {
|
|
||||||
alert((json.error || "Erreur") + (json.message || "Une erreur est survenue"))
|
|
||||||
} else {
|
|
||||||
alert("Succès")
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
alert("Une erreur est survenue")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
btn.addEventListener("click", handleRegister)
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
34
data/static/register.js
Normal file
34
data/static/register.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
const btn = document.getElementById("registerBtn")
|
||||||
|
const emailInput = document.getElementById("email")
|
||||||
|
const usernameInput = document.getElementById("username")
|
||||||
|
const passwordInput = document.getElementById("password")
|
||||||
|
|
||||||
|
async function handleRegister() {
|
||||||
|
try {
|
||||||
|
const response = await fetch("https://yggdrasil.azures.fr/register", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
email: emailInput.value,
|
||||||
|
username: usernameInput.value,
|
||||||
|
password: passwordInput.value
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
const json = await response.json()
|
||||||
|
|
||||||
|
if (json.code !== 200) {
|
||||||
|
alert((json.error || "Erreur") + (json.message || "Une erreur est survenue"))
|
||||||
|
} else {
|
||||||
|
alert("Succès")
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
alert("Une erreur est survenue")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
btn.addEventListener("click", handleRegister)
|
||||||
|
})
|
||||||
Loading…
x
Reference in New Issue
Block a user