title: Getting JSON data out of Array Variable React
body: <p>I have a <code>jsx</code> file with code</p>
  
  <pre><code>var React = require('react');
  var CreateReactClass = require('create-react-class');
  
  
  var url = "192.168.1.1:8081/json";
  let data = [];
  
  fetch(url)
  .then(response =&gt; response.json())
  .then(result =&gt; data.push(result));
  
  console.log(data);
  console.log(data[1].name);
  </code></pre>
  
  <p>console.log(data); 
  returns data but I can't seem to get any specific attributes out from it.
  console.log(data[1].name); just returns: TypeError: data[1] is undefined.</p>
  
  <p>on the URL address I have <code>json</code></p>
  
  <pre><code>[
   {
    "id": "2",
    "name": "led",
    "color": "blue"
   },
   {
    "id": "3",
    "name": "le",
    "color": "red"
    }
  ]
  </code></pre>
  
  <p>for some reason the length of my data array is 0 even after pushing json data into it.</p>
  
  <p>How can I get console to log an attribute from data variable like <code>"name":"le"</code>.</p>