31 lines
1.0 KiB
JavaScript
31 lines
1.0 KiB
JavaScript
|
|
function register() {
|
|
fetch('https://dragonmaster.pl/inz/user/create', {
|
|
method: "PUT",
|
|
headers: {
|
|
'Content-type': 'application/json'
|
|
},
|
|
body: JSON.stringify(
|
|
{
|
|
"username": document.getElementById("regusername").value,
|
|
"name": document.getElementById("regname").value,
|
|
"surname": document.getElementById("regsurname").value,
|
|
"password": document.getElementById("regpassword").value,
|
|
"mail": document.getElementById("regmail").value,
|
|
"phone": document.getElementById("regphone").value
|
|
}
|
|
)
|
|
}
|
|
)
|
|
.then(res => {
|
|
if (res.ok) {
|
|
alert("Teraz mozesz się zalogować!")
|
|
window.location.href = '../index.html'
|
|
}
|
|
else { console.log("Coś poszło nie tak!") }
|
|
return res
|
|
})
|
|
.then(res => res.json())
|
|
.then(data => console.log(data))
|
|
.catch(error => console.log(error))
|
|
} |