Skip to content

Instantly share code, notes, and snippets.

@szaranger
Created August 7, 2022 00:54
Show Gist options
  • Save szaranger/68afffc90799ed75069837086218b984 to your computer and use it in GitHub Desktop.
Save szaranger/68afffc90799ed75069837086218b984 to your computer and use it in GitHub Desktop.
import useSWR from 'swr';
const Post = () => {
const { data, error } = useSWR('/api/post/123', fetch);
if (error) {
return <div>Error loading post!</div>;
}
if (!data) {
return <div>Loading...</div>;
}
return <div>{data}</div>;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment