Skip to content

Instantly share code, notes, and snippets.

@noximus
Created June 20, 2020 16:02
Show Gist options
  • Save noximus/4d1ece65ffe1eb5588b34f7aed1944de to your computer and use it in GitHub Desktop.
Save noximus/4d1ece65ffe1eb5588b34f7aed1944de to your computer and use it in GitHub Desktop.
Axios & Hooks
function Nox() {
const [data, setData] = React.useState({});
React.useEffect(() => {
axios.get('/nox-daily-message').then(({ data }) => {
setData(data);
});
}, []);
return data.ywmib ? <strong>{data.ywmib}</strong> : <div>Loading...</div>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment