Browse Source

handle errors from server

master
Jørgen Lien Sellæg 6 years ago
parent
commit
060ac4f41e
  1. 11
      src/Events.js

11
src/Events.js

@ -115,9 +115,14 @@ export default function Events() {
useEffect(async () => { useEffect(async () => {
if (events === null) { if (events === null) {
const res = await fetch(endpoint, fetch_options) let result = []
const result = await res.json() try {
setEvents(events) const res = await fetch(endpoint, fetch_options)
result = await res.json()
} catch (error) {
console.error(error)
}
setEvents(result)
} }
}, [events]) }, [events])

Loading…
Cancel
Save