title: how to make my url work for all my buttons in Reactjs?
body: <p>I would like that when I click on one of the 3 buttons it displays in the console, the country of buttons! I created this code there but the country is not defined, I don't know how to do it</p>
  <p>For example :
  I would like that when I click on the <code>&lt;Button&gt;France&lt;/Button&gt;</code> in the console:
  an object where there are the values ​​of state.</p>
  <pre><code>import React, { Component } from 'react';
  import './App.css';
  import 'bootstrap/dist/css/bootstrap.min.css';
  import Button from './components/Button';
  
  class App extends Component {
  
    constructor() {
      super();
  
      this.state = {
        name: '',
        capital: &quot;&quot;,
        flag: &quot;&quot;,
        population: 0,
        region: &quot;&quot;,
  
      }
    }
  
    componentDidMount(country) {
      const url = `https://restcountries.eu/rest/v2/name/${country}`;
      
      fetch(url)
        .then(res =&gt; res.json())
        .then(json =&gt;
          this.setState({
            name: json[0].name,
            capital: json[0].capital,
            flag: json[0].flag,
            population: json[0].population,
            region: json[0].region,
          }))
        .catch(error =&gt; error);
  
      console.log(this.state)
    }
  
    render() {
      return (
        &lt;div className=&quot;App&quot;&gt;
  
          &lt;p&gt; name= {this.state.name}&lt;/p&gt;
          &lt;p&gt; capital= {this.state.capital}&lt;/p&gt;
          &lt;p&gt; flag= {this.state.flag}&lt;/p&gt;
          &lt;p&gt; population= {this.state.population}&lt;/p&gt;
          &lt;p&gt; region= {this.state.region}&lt;/p&gt;
  
          &lt;Button onClick={this.componentDidMount.bind(this, 'france')}&gt;France&lt;/Button&gt;
          &lt;Button onClick={this.componentDidMount.bind(this, 'brazil')}&gt;Brazil&lt;/Button&gt;
          &lt;Button onClick={this.componentDidMount.bind(this, 'croatia')}&gt;Croatia&lt;/Button&gt;
        &lt;/div&gt;
      );
    }
  }
  
  export default App;
  </code></pre>