iching-broker-level2/frontend/event.ts
Christopher Hase f5265a4e1d
All checks were successful
ci / build (push) Successful in 1m7s
run in docker part 1.0
2025-04-16 13:53:25 +02:00

22 lines
738 B
TypeScript

function handleClick(): void {
console.log("Der Button wurde geklickt!");
const deployMode = (window as { DEPLOY_MODE?: 'docker' | 'k8s' }).DEPLOY_MODE ?? 'k8s';
const endpoint =
deployMode === 'docker'
? 'http://localhost:8090/iching/api/command'
: '/iching/api/command';
console.log(`DEPLOY_MODE=${deployMode}, sende POST an: ${endpoint}`);
fetch(endpoint, { method: 'POST' })
.then(res => res.text())
.then(text => console.log("HTTP-Server says:", text))
.catch(error => console.error("HTTP-Server - Error:", error));
}
document.addEventListener("DOMContentLoaded", () => {
const button = document.getElementById("myButton");
button?.addEventListener("click", handleClick);
});