title: How to Fetch Json with React-Table library
body: <p>the example to which I refer is the following:
  <a href="https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/sub-components" rel="nofollow noreferrer">https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/sub-components</a></p>
  
  <p>I would like to fetch a json file and pass the elements of the latter into the table instead of generating them as in the previous example.
  The instructions for making fetch are clear to me but I can't understand how to integrate them in the "makeData" file.</p>
  
  <p>This is my "makeData" code:</p>
  
  <pre><code>import ReactDOM from 'react-dom';
  
  const range = len =&gt; {
    const arr = []
    for (let i = 0; i &lt; len; i++) {
      arr.push(i)
    }
    return arr
  }
  
  const newPerson = () =&gt; {
    fetch('http://localhost:5000/api/azienda')
    .then(res =&gt; res.json())
  
  
   //   .then((rows) =&gt; {
    //     ReactDOM.render(this.makeData(rows), document.getElementById('root'));
     //   });
  }
  
  export default function makeData(...lens) {
    const makeDataLevel = (depth = 0) =&gt; {
      const len = lens[depth]
      return range(len).map(d =&gt; {
        return {
          ...newPerson(),
          subRows: lens[depth + 1] ? makeDataLevel(depth + 1) : undefined,
        }
      })
    }
  
    return makeDataLevel()
  }
  </code></pre>
  
  <p>For any advice I will thank you</p>