import React, { Component } from 'react'; import Service from './Service.js'; import './App.css'; const ENDPOINT = 'https://elstatus.stayathomeserver.club/api/status' export default class App extends Component { state = { loading: true, error: null, metrics: null, }; componentDidMount() { fetch(ENDPOINT) .then((resp) => resp.json()) .then((data) => { this.setState({ metrics: data, loading: false }); }) .catch((error) => { this.setState({ error: error.toString() }); }) } render() { const metrics = !this.state.metrics ? null : (
{Object.entries(this.state.metrics.status) .map(([name, info]) => ) }
); return (

elstatus

{this.state.loading ?
Loading metrics...
: null} {this.state.error ?
Error: {this.state.error}
: null} {metrics}
); } }