Skip to content

Instantly share code, notes, and snippets.

@beardedtim
Created June 5, 2020 16:00
Show Gist options
  • Save beardedtim/1e72d11df133fe2a6c471a0a69e1a678 to your computer and use it in GitHub Desktop.
Save beardedtim/1e72d11df133fe2a6c471a0a69e1a678 to your computer and use it in GitHub Desktop.
import React, {useState, useEffect} from 'react';
import Axios from 'axios';
import './App.css';
import AutoComplete from './AutoComplete'
function App() {
const [globalStats, setGlobalStats] = useState({})
const [countryStats, setCountryStats] = useState({})
const retriveStats = () => Axios.get('https://api.covid19api.com/summary')
.then(res => {
setGlobalStats(res.data.Global)
setCountryStats(res.data.Countries)
})
useEffect(retriveStats, [])
return (
<div className="App">
<header>Covid19 Stats</header>
{Object.entries(globalStats)
.map(([key, value ], i) => (
{/* cannot have more than one value that has ID global
so changing to classname
*/}
<div className='global' key={i}>
<div id="key">{key}: </div>
<div>{formatVal(value)}</div>
</div>
))
}
<div className='App-Component'>
<AutoComplete countryNames={countryStats && countryStats.map(c => c.Country)}/>
</div>
</div>
);
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment