// Hookbin is a free service that enables you to collect, parse, and view HTTP requests.
// Create your unique endpoints to inspect headers, body, query strings, cookies, uploaded files, and much more.
// https://hookbin.com/
// Your hookbin URL goes here:
const url = "";
const formEl = document.querySelector("form");
formEl.addEventListener("submit", async (e) => {
e.preventDefault();
const formData = new FormData(formEl);
const formDataSerialized = Object.fromEntries(formData);
const jsonObject = {
...formDataSerialized,
sendToSelf: formDataSerialized.sendToSelf ? true : false,
};
try {
const response = await fetch(url, {
method: "POST",
body: JSON.stringify(jsonObject),
headers: {
"Content-Type": "application/json",
},
});
const json = await response.json();
console.log(json);
} catch (e) {
console.error(e);
alert("there as an error");
}
});