diff --git a/priv/frontend/src/components/Dashboard.js b/priv/frontend/src/components/Dashboard.js index 8e5aad1..8753363 100644 --- a/priv/frontend/src/components/Dashboard.js +++ b/priv/frontend/src/components/Dashboard.js @@ -20,8 +20,12 @@ export default class Dashboard extends Component { } async componentDidMount () { - await this.loadMetrics() - await this.loadIncident() + try { + await this.loadMetrics() + await this.loadIncident() + } catch (error) { + this.setState({ error: error.toString() }) + } this.setState({ loading: false }) if (this.state.error) { @@ -95,24 +99,14 @@ export default class Dashboard extends Component { async loadMetrics () { log('loading metrics') - try { - var resp = await strictFetch(`${DOMAIN}/api/status`) - } catch (error) { - this.setState({ error }) - } - + const resp = await strictFetch(`${DOMAIN}/api/status`) this.setState({ metrics: await resp.json() }) } async loadIncident () { log('loading current incident') - try { - var resp = await strictFetch(`${DOMAIN}/api/incidents/current`) - } catch (error) { - this.setState({ error }) - } - + const resp = await strictFetch(`${DOMAIN}/api/incidents/current`) this.setState({ incident: await resp.json() }) } @@ -149,7 +143,7 @@ export default class Dashboard extends Component { {this.state.error ? (
- Error: {this.state.error} + {this.state.error}
) : null}