title: How to send and receive large JSON data
body: <p>I'm relatively new to full-stack development, and currently trying to figure out an effective way to <code>send</code> and <code>fetch</code> large data between my front-end (React) and back-end (Express) while minimizing memory usage. Specifically, I'm building a mapping app which requires me to play around with large JSON files (10-100mb). </p>
  
  <p>My current setup works for smaller JSON files:</p>
  
  <p><strong>Backend:</strong></p>
  
  <pre><code>const data = require('../data/data.json');
  
  router.get('/', function(req, res, next) {
    res.json(data);
  });
  </code></pre>
  
  <p><strong>Frontend:</strong> </p>
  
  <pre><code>componentDidMount() {
        fetch('/')
        .then(res =&gt; res.json())
        .then(data =&gt; this.setState({data: data}));
    }
  </code></pre>
  
  <p>However, if <code>data</code> is bigger than ~40mb, the backend would crash if I test on local due to running out of memory. Also, holding onto the data with <code>require()</code> takes quite a bit of memory as well.</p>
  
  <p>I've done some research and have a general understanding of JSON parsing, stringifying, streaming, and I think the answer lies somewhere with using chunked json stream to send the data bit by bit, but am pretty much at a loss on its implementation, especially using a single <code>fetch()</code> to do so (is this even possible?).</p>
  
  <p>Definitely appreciate any suggestions on how to approach this.</p>