43 lines
1.3 KiB
HTML
43 lines
1.3 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="pl">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Lekcja 2.3</title>
|
|
</head>
|
|
<body>
|
|
<label for="imie">Imię: </label>
|
|
<input type="text" name="imie" id="imie"><br>
|
|
|
|
<label for="nazwisko">Nazwisko: </label>
|
|
<input type="text" name="nazwisko" id="nazwisko"><br>
|
|
|
|
<button id="b1">Logowanie</button>
|
|
|
|
<script>
|
|
document.getElementById("b1").onclick = function() {
|
|
const data = JSON.stringify({
|
|
"imie": document.getElementById("imie").value,
|
|
"nazwisko": document.getElementById("nazwisko").value
|
|
})
|
|
const options = {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json"
|
|
},
|
|
body: data
|
|
}
|
|
fetch("/login", options)
|
|
.then(function(response) {
|
|
return response.json()
|
|
})
|
|
.then(function(data) {
|
|
console.log(JSON.stringify(data))
|
|
})
|
|
.catch(function(error) {
|
|
console.error(error)
|
|
})
|
|
}
|
|
</script>
|
|
</body>
|
|
</html> |