Formularz w v0
Pomiń Server Actions i Resend. Wystarczy fetch do Formgong.
- Wygeneruj sekcję promptem.
- Sprawdź nagłówki Accept i Content-Type.
- Sukces to pole success.
- Klucz zostaw we froncie.
Prompt
Dodaj sekcję kontaktową. Nie używaj Server Actions ani Resend. Formgong: POST https://formgong.com/submit, access_key fk_your_access_key. Pola name, email, message, ukryte botcheck. fetch z Content-Type application/json i Accept: application/json. Sukces: result.success. Bez plików.
fetch
async function onSubmit(event) {
event.preventDefault();
const fields = Object.fromEntries(new FormData(event.currentTarget));
const response = await fetch("https://formgong.com/submit", {
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify({ ...fields, access_key: "fk_your_access_key" }),
});
const result = await response.json();
if (!result.success) throw new Error(result.message || "Formgong error");
}