From d11ef4aa4c9eeb0267ea899b8ed8cd6b088bed6a Mon Sep 17 00:00:00 2001 From: phoenixpereira Date: Tue, 25 Feb 2025 22:07:08 +1030 Subject: [PATCH] chore(contact): Replace fetch with ky for API requests in contact form --- src/app/contact/Form.tsx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/app/contact/Form.tsx b/src/app/contact/Form.tsx index ab487d0..0b74314 100644 --- a/src/app/contact/Form.tsx +++ b/src/app/contact/Form.tsx @@ -3,6 +3,7 @@ import Button from '@/components/Button'; import Duck from '@/components/Duck'; import { createSubmit } from 'just-submit'; +import ky from 'ky'; import { useState } from 'react'; export default function Form({ className }: { className?: string }) { @@ -10,12 +11,8 @@ export default function Form({ className }: { className?: string }) { const [isSuccess, setIsSuccess] = useState(false); const submit = createSubmit({ fullName: 'string', email: 'string', message: 'string' }); const handleSubmit = submit(async (data) => { - const response = await fetch('/api/contact', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify(data), + const response = await ky.post('/api/contact', { + json: data, }); if (response.ok) { setSubmitInfo('Message sent successfully!');