Implement payment page

This commit is contained in:
Laurent
2025-12-04 08:48:09 +01:00
parent c99d8068f9
commit dd7a63c22f
5 changed files with 82 additions and 32 deletions

View File

@@ -33,7 +33,7 @@
<script>
let btn = document.getElementById("connect-button");
btn.addEventListener("click", () => {
btn.addEventListener("click", async () => {
let username = document.getElementById("username-field").value;
let pwd = document.getElementById("password-field").value;
@@ -42,20 +42,22 @@
password: pwd
};
fetch("/login", {
await fetch("/login", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(data)
})
.then(response => response.text())
.then(result => {
console.log("Server response:", result);
})
.catch(error => {
console.error("Error:", error);
});
body: JSON.stringify(data)})
.then(response => {
if(response.ok) {
window.location.href = "/payment";
} else {
throw new Error("Authentication request failed")
}
})
.catch(error => {
console.error("Error:", error);
});
});
</script>