import { useRef, type FormEvent } from "react"; export function APITester() { const responseInputRef = useRef(null); const testEndpoint = async (e: FormEvent) => { e.preventDefault(); try { const form = e.currentTarget; const formData = new FormData(form); const endpoint = formData.get("endpoint") as string; const url = new URL(endpoint, location.href); const method = formData.get("method") as string; const res = await fetch(url, { method }); const data = await res.json(); responseInputRef.current!.value = JSON.stringify(data, null, 2); } catch (error) { responseInputRef.current!.value = String(error); } }; return (