iching-broker-level2/dist/frontend/event.mjs
Christopher Hase 628855b5d9
All checks were successful
ci / build (push) Successful in 1m11s
add config.json again
2025-04-17 14:46:32 +02:00

18 lines
837 B
JavaScript

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