title: How to parse Json data by chunks in NodeJs
body: <p>I'm creating a REST API that gets raw data from the internet then apply a REGEX to it and return it in JSON format.</p>
  
  <p>this is my function for getting Data as JSON.<br>
  first i'm using got() to get the raw data than I apply ANIME_LIST_REGEX.exec() to filter it with the regular expression to make it in JSON format.</p>
  
  <pre><code>async function getAnimeList(url) {
  const {body} = await got(url);
  
  let ANIME_LIST_DATA = ANIME_LIST_REGEX.exec(body)
  
  if (!ANIME_LIST_DATA) {
      return null;
  }
  
  return {
      animeList: ANIME_LIST_DATA[1]
  };
  </code></pre>
  
  <p>}</p>
  
  <p>in this endpoint I'm retreiving the data from the 1st function and parsing the JSON, the return it as a response.</p>
  
  <pre><code>app.get('/anime-list', async (req, res, next) =&gt; {
      const appData = await getAnimeList(URL_BASE_ANIME_LIST);
      var listJson = JSON5.parse(appData.animeList)
      res.json(listJson)
  })
  </code></pre>
  
  <p>The issue is that the returned array is pretty big (5000 entries of js objects) and the request takes long time to return and show the array<br>
  What I want to do is to return a chunck of that array every time I call the function or reach the endpoint.<br>
  Tried several methods but none of them made sense.<br>
  Does anyone got an idea? </p>