Skip to content

Instantly share code, notes, and snippets.

@simoneb
Last active February 19, 2019 10:59
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 simoneb/1195a5b056541a87f2abdfe217bd00a6 to your computer and use it in GitHub Desktop.
Save simoneb/1195a5b056541a87f2abdfe217bd00a6 to your computer and use it in GitHub Desktop.
function useAxios(url) {
const [response, setResponse] = React.useState()
React.useEffect(() => {
axios(url)
.then(response => setResponse(response))
.catch(error => setResponse(error))
}, [url])
return response
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment