28 lines
825 B
JavaScript
28 lines
825 B
JavaScript
document.getElementById("signup").addEventListener("click", async function (e) {
|
|
let storage = 0
|
|
try {
|
|
storage = parseInt(document.getElementById("storage").value)
|
|
} catch (e) {
|
|
alert("Invalid storage amount")
|
|
}
|
|
|
|
let response = await fetch("/api/signup", {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json"
|
|
},
|
|
body: JSON.stringify({
|
|
username: document.getElementById("username").value,
|
|
domain: document.getElementById("domain").value,
|
|
storage: storage,
|
|
token: localStorage.getItem("SECRET-token")
|
|
})
|
|
})
|
|
|
|
if (response.status === 200) {
|
|
window.location.href = "/settings"
|
|
} else {
|
|
let data = await response.json()
|
|
alert(data["error"])
|
|
}
|
|
}) |