diff --git a/14_Day_Component_Life_Cycles/14_component_life_cycles_boilerplate/src/index.js b/14_Day_Component_Life_Cycles/14_component_life_cycles_boilerplate/src/index.js index b9f802e..74cf6e2 100644 --- a/14_Day_Component_Life_Cycles/14_component_life_cycles_boilerplate/src/index.js +++ b/14_Day_Component_Life_Cycles/14_component_life_cycles_boilerplate/src/index.js @@ -15,49 +15,49 @@ class App extends Component { console.log('I am componentDidMount and I will be last to run.') const API_URL = 'https://restcountries.eu/rest/v2/all' fetch(API_URL) - .then((response) => { - return response.json() - }) - .then((data) => { - console.log(data) - this.setState({ - data, + .then((response) => { + return response.json() + }) + .then((data) => { + console.log(data) + this.setState({ + data, + }) + }) + .catch((error) => { + console.log(error) }) - }) - .catch((error) => { - console.log(error) - }) } renderCountries = () => { return this.state.data.map((country) => { return ( -
Population: {country.population}
+Population: {country.population}
+There are {this.state.data.length} countries in the api
-There are {this.state.data.length} countries in the api
+