diff --git a/docs/basic-features/data-fetching.md b/docs/basic-features/data-fetching.md index 937181cbedbcf..436ee3fbe54fb 100644 --- a/docs/basic-features/data-fetching.md +++ b/docs/basic-features/data-fetching.md @@ -825,8 +825,10 @@ The team behind Next.js has created a React hook for data fetching called [**SWR ```jsx import useSWR from 'swr' +const fetcher = (url) => fetch(url).then((res) => res.json()) + function Profile() { - const { data, error } = useSWR('/api/user', fetch) + const { data, error } = useSWR('/api/user', fetcher) if (error) return
failed to load
if (!data) return
loading...