people.lee_robinson used this in his course instead of React Query.
The default use-case looked a lot simplier. I wonder if:
a) We can simplify next.react-query implementation. b) We should use this instead.
import useSWR from "swr";
const fetcher = url => fetch(url).then(res => res.json());
export default function Index() {
const { data, error } = useSWR("/api/item?id=asdsa", fetcher);
if (error) return <div>Failed to load.</div>;
if (!data) return <div>Loading ...</div>;
return <div>{JSON.stringify(data, null, 2)}</div>;
}