v3.3.2
Features
Adds the submit method
The submit method is expected to be used in a <form> element. It will send the request body as FormData.
Usage:
"use client"
import { useMutation } from "http-react"
export default function Home() {
// You can also read 'isLoading'
const { submit, isPending, error } = useMutation("/api/test", {
method: "POST",
})
return (
<main className="p-16">
<form action={submit}>
<input
type="text"
name="email"
className="border-2 border-black p-2 rounded-lg"
/>
</form>
{isPending && <p>Submitting</p>}
{error && <p>Error</p>}
</main>
)
}