22 lines
738 B
TypeScript
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);
|
|
});
|