title: Fill a reactjs map with json objects from request response inside for loop
body: <p>I'm working on a React dashboard and I found a library that helps me build a line chart using a json object.</p>
  
  <p>So I'm trying to get 7 objects from my GET requests inside a for loop and fill the <code>data</code> map with them.</p>
  
  <p>This is the json object that I get:</p>
  
  <pre><code>{
    "year": "2020-03-03",
    "uses": 0
  }
  </code></pre>
  
  <p>I want to have an object like this:</p>
  
  <pre><code>data = [
    {
      year: 2014,uses: 255,
    }, {
      year: 2016,uses: 250,
    }, {
      year: 2018,uses: 540,
    },
  ];
  </code></pre>
  
  <p>I'm trying to fill the data map inside <code>componentWillMount()</code> like this:</p>
  
  <pre class="lang-js prettyprint-override"><code>constructor(props) {
    super(props);
    this.state = {
      data ,
    };
  }
  
  componentWillMount(){
    for (let i = 0; i &lt; 7; i++) {
      axios.get("http://localhost:5000/transfer/getUsesByDay/"+i).then(
        res =&gt; {
          console.log("http://localhost:5000/transfer/getUsesByDay/"+i)
          console.log(res.data)
          //TODO : set state =&gt; Fill Data
        }
      )
    }
  }
  
  </code></pre>