title: Non-recursive pagination with promises
body: <p>With a typical pagination API that returns</p>
  
  <pre><code>{
      "data": ...,
      "nextPageHref": &lt;url&gt;
  }
  </code></pre>
  
  <p>how can I fetch all the pages in JavaScript <strong>without using recursion</strong>?</p>
  
  <p>(the recursive solution is something like)</p>
  
  <pre><code>fetchPaginated(url) {
    return fetch(url).then(result =&gt; result.nextPageHref
      ? fetchPaginated(result.nextPageHref).then(results =&gt; _.concat(result, results))
      : result
  }
  </code></pre>