iching-broker-level2/frontend/event.ts
Christopher Hase 131258aa86
All checks were successful
ci / build (push) Successful in 1m11s
add http-server part 7.9.4 CORS
2025-04-11 12:34:35 +02:00

28 lines
No EOL
902 B
TypeScript

function handleClick(): void {
console.log("Der Button wurde geklickt!");
alert("Hallo von TypeScript!");
fetch("http://localhost:8090/api/command", {
method: "POST",
headers: {
"Content-Type": "application/json", // Füge dies hinzu, wenn du JSON sendest
}
})
.then(res => res.text())
.then(text => console.log("Server sagt:", text))
.catch(error => console.error("Fehler:", error));
/*fetch("/api/command", { method: "POST" })
.then(res => res.text())
.then(text => console.log("Server sagt:", text));*/
/*fetch("https://192-168-197-2.c-one-infra.de/api/command", { method: "POST" })
.then(res => res.text())
.then(text => console.log("Server sagt:", text)); */
}
document.addEventListener("DOMContentLoaded", () => {
const button = document.getElementById("myButton");
button?.addEventListener("click", handleClick);
});