Skip to content

Instantly share code, notes, and snippets.

@brunosabot
Created January 29, 2022 21:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brunosabot/70f06dc89a783020c6898c1873f4972c to your computer and use it in GitHub Desktop.
Save brunosabot/70f06dc89a783020c6898c1873f4972c to your computer and use it in GitHub Desktop.
export function MyFetchingComponent() {
const [serverData, setServerData] = useState({ name: "" });
useEffect(() => {
fetch("https://brunosabot.dev/api/hello/")
.then((result) => result.json())
.then((data) => setServerData(data));
}, []);
return <div>{serverData.name}</div>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment