add http-server part 7.9.13 CORS
This commit is contained in:
parent
0754a99bbb
commit
e403d380a8
1 changed files with 13 additions and 10 deletions
|
@ -3,15 +3,24 @@ function handleClick(): void {
|
||||||
console.log("Der Button wurde geklickt!");
|
console.log("Der Button wurde geklickt!");
|
||||||
alert("Hallo von TypeScript!");
|
alert("Hallo von TypeScript!");
|
||||||
|
|
||||||
fetch("http://localhost:8090/api/command", {
|
//fetch("http://localhost:8090/api/command", {
|
||||||
method: "POST",
|
|
||||||
|
fetch("/api/command", {
|
||||||
|
method: "POST"
|
||||||
|
/*,
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json", // Füge dies hinzu, wenn du JSON sendest
|
"Content-Type": "application/json", // Füge dies hinzu, wenn du JSON sendest
|
||||||
}
|
}*/
|
||||||
})
|
})
|
||||||
.then(res => res.text())
|
.then(res => res.text())
|
||||||
.then(text => console.log("Server sagt:", text))
|
.then(text => console.log("Server sagt:", text))
|
||||||
.catch(error => console.error("Fehler:", error));
|
.catch(error => console.error("Fehler:", error));
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
const button = document.getElementById("myButton");
|
||||||
|
button?.addEventListener("click", handleClick);
|
||||||
|
});
|
||||||
|
|
||||||
/*fetch("/api/command", { method: "POST" })
|
/*fetch("/api/command", { method: "POST" })
|
||||||
.then(res => res.text())
|
.then(res => res.text())
|
||||||
|
@ -19,10 +28,4 @@ function handleClick(): void {
|
||||||
|
|
||||||
/*fetch("https://192-168-197-2.c-one-infra.de/api/command", { method: "POST" })
|
/*fetch("https://192-168-197-2.c-one-infra.de/api/command", { method: "POST" })
|
||||||
.then(res => res.text())
|
.then(res => res.text())
|
||||||
.then(text => console.log("Server sagt:", text)); */
|
.then(text => console.log("Server sagt:", text)); */
|
||||||
}
|
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
|
||||||
const button = document.getElementById("myButton");
|
|
||||||
button?.addEventListener("click", handleClick);
|
|
||||||
});
|
|
Loading…
Reference in a new issue