I am just beginning to learn javascript and am hung up on getting my code to POST submission data to a test api endpoint. My console is telling me ReferenceError: jsonObject is not defined. Please help, thanks
<form id="jobData" method="post">
<fieldset>
<label for="machineField">Heavy Equipment Machine Type</label>
<input name="Machine" type="text"" id="machineField">
</input>
<label for="workField">Work To Be Performed</label>
<input type="text" name="work" id="workField">
<label for="detailsField">Other Important Details</label>
<textarea name="details" id="detialsField" cols="30" rows="10"></textarea>
<button type="submit" name="submit">SEND</button>
</fieldset>
</form>
<script>
const url = "https://6fp4lq4r8d.api.quickmocker.com";
const formEl = document.querySelector("form");
formEl.addEventListener("submit", async (e) => {
e.preventDefault();
const formData = new FormData(formEl);
const formDataSerialized = Object.fromEntries(formData);
console.log(formDataSerialized, "formDataSerialized");
try {
const response = await fetch(url, {
method: 'POST',
body: JSON.stringify(jsonObject),
headers: {
'Content-Type': 'application/jason'
}
});
const json = await response.json();
console.log(json);
} catch(e){
console.error(e);
alert("An Error Occured");
}
});
</script>