const domain = document.querySelector("#domain"); const commonname = document.querySelector("#commonname"); const organizationname = document.querySelector("#organizationname"); const password = document.querySelector("#password"); const organizationunit = document.querySelector("#organizationunit"); const createcert = document.querySelector("#createcert"); createcert.addEventListener("click", () => { const domainValue = domain.value; const commonnameValue = commonname.value; const organizationnameValue = organizationname.value; const passwordValue = password.value; const organizationunitValue = organizationunit.value; fetch(window.location.origin + "/api/certs/create", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ dns: [domainValue], commonname: commonnameValue, organizationname: [organizationnameValue], organizationunit: [organizationunitValue], password: passwordValue, }), }) .then((data) => data.json()) .then((jsondata) => { if (jsondata.status === "success") { getCerts(); var createmodal = bootstrap.Modal.getOrCreateInstance( document.getElementById("create_certificate"), ); createmodal.hide(); alert("Certificate created successfully"); } else { alert("Failed to create certificate:", jsondata.error); } }) .catch((error) => { alert("An error occurred:", error); }); });