import { useEffect, useState } from "react"; // minimal useQuery lookalike export function useApi( url: string, options?: RequestInit ) { const [loading, setLoading] = useState(true); const [data, setData] = useState(); const [error, setError] = useState(); useEffect(() => { setData(undefined); setError(undefined); setLoading(true); fetch(url, options) .then((res) => res.json()) .then((body) => setData(body)) .catch((err) => setError(err)) .finally(() => setLoading(false)); }, [url, options]); return { loading, data, error }; }