const form = { name: "", email: "", message: "" } const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (!form.name || !form.email || !form.message) { console.log("Please fill all the fields"); return; } const response = await fetch("/api/contact", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(form), }); const data = await response.json(); console.log(data); }
No output yet. Run your code to see results.