Loading page
Native fetch, AbortSignal.timeout for a hard deadline, and a status check.
export async function submitContact(payload) {
const response = await fetch("https://formivo.faizyab.me/api/f/YOUR_FORM_ID", {
method: "POST",
headers: { "Content-Type": "application/json", Accept: "application/json" },
body: JSON.stringify(payload),
signal: AbortSignal.timeout(10_000),
}).catch((error) => ({ ok: false, error }));
if (!response.ok) {
throw new Error("Contact submission failed");
}
return response.json(); // { success: true, leadId }
}201 with { success: true, leadId }; 429 includes Retry-After.
| Symptom | Fix |
|---|---|
| fetch is not defined | Upgrade to Node 18+ or use undici. |
| Request hangs | Pass an AbortSignal; there is no default timeout. |