diff --git a/priv/frontend/src/components/App.js b/priv/frontend/src/components/App.js index e6aeb02..d6c4507 100644 --- a/priv/frontend/src/components/App.js +++ b/priv/frontend/src/components/App.js @@ -151,13 +151,23 @@ export default class App extends Component { log('loading metrics') try { - const resp = await fetch(`${DOMAIN}/api/status`) - const json = await resp.json() - - this.setState({ metrics: json, loading: false }) + var resp = await fetch(`${DOMAIN}/api/status`) } catch (err) { - this.setState({ error: err.toString() }) + this.setState({ + error: `Network error: ${err}`, + }) } + + if (!resp.ok) { + this.setState({ + error: `Failed to fetch stats (${resp.status} ${resp.statusText})`, + }) + return + } + + const json = await resp.json() + + this.setState({ metrics: json, loading: false }) } render () {