/api added with docker

This commit is contained in:
2024-03-20 17:14:46 -05:00
parent 6dcd18600e
commit 8a360d09ee
305 changed files with 29241 additions and 13 deletions

View File

@@ -0,0 +1,39 @@
// Get reference to the form
const form = document.querySelector("form");
// Function to handle form submission
async function handleSubmit(event) {
event.preventDefault();
// Get the value entered in the input field
const productCode = document.getElementById("productCode").value;
try {
// Send POST request to server
const response = await fetch("http://localhost:3000/submit", {
method: "POST",
headers: {
"Content-Type": "application/json", // Indicate that the request body is JSON
},
body: JSON.stringify({ productCode }),
});
if (!response.ok) {
throw new Error(
`Network response was not ok, status: ${response.status}`
);
}
// Optional: Handle JSON response data here
// const data = await response.json();
// console.log(data);
console.log("Data submitted successfully");
// Optional: Update UI to reflect success
} catch (error) {
console.error("Error submitting data:", error);
// Optional: Update UI to reflect error
}
}
// Add event listener to the form's submit event
form.addEventListener("submit", handleSubmit);