Skip to content

Instantly share code, notes, and snippets.

@cpv123
Last active January 15, 2020 02:24
Show Gist options
  • Save cpv123/f2454bf55cfbcdd1e4ed41c9f44bf36f to your computer and use it in GitHub Desktop.
Save cpv123/f2454bf55cfbcdd1e4ed41c9f44bf36f to your computer and use it in GitHub Desktop.
useEffect(() => {
const fetchShops = async () => {
try {
const shops = await axios.get(process.env.GATSBY_COFFEE_SHOPS_URL)
setShops(shops.data.Items)
} catch (err) {
setShopsError(true)
} finally {
setShopsLoading(false)
}
}
fetchShops()
}, [])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment