-
-
Save brunosabot/6dd2b044779868123fdbdd7c8f6bfa94 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import useSWR from "swr"; | |
const fetcher = (...args) => fetch(...args).then((res) => res.json()); | |
function MyRenderingComponent() { | |
const { data, error } = useSWR("https://brunosabot.dev/api/hello/", fetcher); | |
if (error) return <div>An error has occurred</div>; | |
if (!data) return <div>Loading...</div>; | |
return <div>{data.name}</div>; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment