File size: 392 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import useSWR from "swr";

const fetcher = (url: string) => fetch(url).then((res) => res.text());

export default function Index() {
  const { data, error, isLoading } = useSWR<string>("/api/cookies", fetcher);

  if (error) return <div>Failed to load</div>;
  if (isLoading) return <div>Loading...</div>;
  if (!data) return null;

  return <div>{`Cookie from response: "${data}"`}</div>;
}