Skip to content

Commit

Permalink
chore(contact): Replace fetch with ky for API requests in contact form
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenixpereira committed Feb 25, 2025
1 parent d314e53 commit d11ef4a
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/app/contact/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@
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 }) {
const [submitInfo, setSubmitInfo] = useState('');
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!');
Expand Down

0 comments on commit d11ef4a

Please sign in to comment.