document.getElementById("orderForm").addEventListener("submit", function(e) {
e.preventDefault();
const curry = parseInt(this.curry.value);
const cake = parseInt(this.cake.value);
const spaghetti = parseInt(this.spaghetti.value);
const order = { curry, cake, spaghetti };
fetch("/order", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(order)
})
.then(res => res.json())
.then(data => {
document.getElementById("result").textContent = data.message;
})
.catch(err => {
document.getElementById("result").textContent = "エラーが発生しました。";
});
});