Skip to content

Commit 553e644

Browse files
committed
add form fix
1 parent 3d94aa9 commit 553e644

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

src/RequestForm.svelte

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,32 +38,35 @@
3838
isSubmitting = true;
3939
submitError = "";
4040
41+
const payload = {
42+
type: requestType,
43+
request: request,
44+
docsLink: docsLink,
45+
email: email,
46+
timestamp: new Date().toISOString(),
47+
};
48+
49+
console.log("Submitting to Zapier:", payload);
50+
4151
try {
4252
const response = await fetch(ZAPIER_WEBHOOK_URL, {
4353
method: "POST",
54+
mode: "no-cors",
4455
headers: {
4556
"Content-Type": "application/json",
4657
},
47-
body: JSON.stringify({
48-
type: requestType,
49-
request: request,
50-
docsLink: docsLink,
51-
email: email,
52-
timestamp: new Date().toISOString(),
53-
}),
58+
body: JSON.stringify(payload),
5459
});
5560
56-
if (response.ok) {
57-
submitSuccess = true;
58-
setTimeout(() => {
59-
closeModal();
60-
}, 2500);
61-
} else {
62-
submitError = "Failed to submit request. Please try again.";
63-
}
61+
// With no-cors mode, we can't read the response, so we assume success
62+
console.log("Zapier webhook response:", response);
63+
submitSuccess = true;
64+
setTimeout(() => {
65+
closeModal();
66+
}, 2500);
6467
} catch (error) {
65-
submitError = "Network error. Please check your connection and try again.";
6668
console.error("Submission error:", error);
69+
submitError = "Failed to submit. Error: " + (error instanceof Error ? error.message : String(error));
6770
} finally {
6871
isSubmitting = false;
6972
}

0 commit comments

Comments
 (0)