canvas-data-fetching
Installation
SKILL.md
Data fetching
Data fetching with SWR
Use SWR for all data fetching. It provides caching, revalidation, and a clean hook-based API.
import useSWR from 'swr';
const fetcher = (url) => fetch(url).then((res) => res.json());
export default function Profile() {
const { data, error, isLoading } = useSWR(
'https://my-site.com/api/user',
fetcher,
);