Skip to content

Instantly share code, notes, and snippets.

@simoneb simoneb/useAxios.js
Last active Feb 19, 2019

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
You can’t perform that action at this time.