iching-broker-level2/frontend/event.ts
Christopher Hase 1d62a62f33
All checks were successful
ci / build (push) Successful in 1m6s
run locally part 1.0
2025-04-16 15:37:16 +02:00

23 lines
866 B
TypeScript

function handleClick(): void {
console.log("Der Button wurde geklickt!");
//const deployMode = (window as { DEPLOY_MODE?: 'docker' | 'k8s' }).DEPLOY_MODE ?? 'k8s';
const deployMode = (window as { DEPLOY_MODE?: 'docker' | 'k8s' | 'local' }).DEPLOY_MODE ?? 'k8s';
const endpoint =
deployMode === 'docker' || deployMode === 'local'
? '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);
});