title: Infinite scroll in Javascript with data from file
body: <p>I want to do infinite scroll in plain Javascript. I saw several tutorials but all of them fetch some random data from some api. I understand the code from tutorials but I don't know how to get data in order, not random.</p>
  
  <p>I want to do something similar like here: <a href="https://codepen.io/FlorinPop17/pen/RwwvKYJ" rel="nofollow noreferrer">https://codepen.io/FlorinPop17/pen/RwwvKYJ</a> but I want to use data from my local file. Let's assume it's data.js and has code like it:</p>
  
  <pre><code>data = [{}, {}] 
  </code></pre>
  
  <p>so it's array of objects and let's assume the content of objects is like here: <a href="https://jsonplaceholder.typicode.com/posts/" rel="nofollow noreferrer">https://jsonplaceholder.typicode.com/posts/</a> </p>
  
  <p>How would you change the code from this codepen to display posts one by one in order? I guess, the function getPost should have parameter "id" and every time this function is called the parameter should be plus 1? But how to do it? Or maybe I should iterate through data.js and on every iteration check if user scrolled to bottom?</p>