Skip to content

Instantly share code, notes, and snippets.

@simoneb
Last active February 19, 2019 10:59
Embed
What would you like to do?
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