29 lines
926 B
JavaScript
29 lines
926 B
JavaScript
const button = document.querySelector("#register")
|
|
|
|
async function register(email, username, password) {
|
|
const response = await fetch("https://yggdrasil.azures.fr/register", {
|
|
method: "POST",
|
|
headers: {
|
|
"content-type": "application/json"
|
|
},
|
|
body: JSON.stringify({
|
|
email,
|
|
username,
|
|
password
|
|
})
|
|
})
|
|
const json = await response.json()
|
|
if (json.code != 200) {
|
|
return iziToast.error({ title: json.error, message: json.message })
|
|
} else {
|
|
console.log(json)
|
|
return iziToast.success({ title: "Succès", message: json.message })
|
|
}
|
|
}
|
|
|
|
button.addEventListener("click", () => {
|
|
const email = document.querySelector("#email").value
|
|
const username = document.querySelector("#username").value
|
|
const password = document.querySelector("#password").value
|
|
register(email, username, password)
|
|
}) |