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 () => {
if (events === null) {
const res = await fetch(endpoint, fetch_options)
const result = await res.json()
setEvents(events)
let result = []
try {
const res = await fetch(endpoint, fetch_options)
result = await res.json()
} catch (error) {
console.error(error)
}
setEvents(result)
}
}, [events])

Loading…
Cancel
Save