iching-broker-level2/frontend/event.ts

24 lines
866 B
TypeScript
Raw Normal View History

2025-04-04 09:48:30 +00:00
function handleClick(): void {
console.log("Der Button wurde geklickt!");
2025-04-16 13:37:16 +00:00
//const deployMode = (window as { DEPLOY_MODE?: 'docker' | 'k8s' }).DEPLOY_MODE ?? 'k8s';
const deployMode = (window as { DEPLOY_MODE?: 'docker' | 'k8s' | 'local' }).DEPLOY_MODE ?? 'k8s';
2025-04-16 11:53:25 +00:00
const endpoint =
2025-04-16 13:37:16 +00:00
deployMode === 'docker' || deployMode === 'local'
2025-04-16 11:53:25 +00:00
? 'http://localhost:8090/iching/api/command'
: '/iching/api/command';
console.log(`DEPLOY_MODE=${deployMode}, sende POST an: ${endpoint}`);
fetch(endpoint, { method: 'POST' })
2025-04-09 13:47:06 +00:00
.then(res => res.text())
2025-04-15 14:28:48 +00:00
.then(text => console.log("HTTP-Server says:", text))
.catch(error => console.error("HTTP-Server - Error:", error));
2025-04-11 13:11:28 +00:00
}
document.addEventListener("DOMContentLoaded", () => {
const button = document.getElementById("myButton");
button?.addEventListener("click", handleClick);
});