Skip to content

Instantly share code, notes, and snippets.

@brunosabot
Created January 29, 2022 21:46
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