title: TypeError: 'NoneType' object is not iterable when
body: <p>I am trying to collect data from a paginated API and for some reason I cannot find a workaround for the <em>'NoneType' object is not iterable TypeError</em>. Please see code below.</p>
  <pre><code>import json 
  import requests
  import fsspec
  from io import BytesIO
  import pandas as pd
  
  parameters = {
      &quot;CreatedAfterUTC&quot;: &quot;2020-01-01T00:00:00&quot;,
      &quot;PageNum&quot;: 1,
      &quot;RecordsPerPage&quot;: 2000
  }
  
  headers = {
  &quot;Content-Type&quot; : &quot;application/json&quot;,
  &quot;Authorization&quot;: str('APIKEY'),
  }
  
  referrals = []
  
  pagenum = 1
  
  while True:
      url = f&quot;https://restapi.erelocation.net/api/v1/GetReferrals?PageNum={pagenum}&amp;RecordsPerPage=2000&quot;
      print(&quot;Requesting&quot;, url)
      resp = requests.get(url, headers=headers, params=parameters)
      data = resp.json()
      for item in data.get('Referral', []):
          if len(data['Referral']) == 0:
              break
      referrals.extend(data['Referral'])
      pagenum = pagenum + 1
  
  </code></pre>
  <p><strong>TypeError: 'NoneType' object is not iterable</strong></p>