UrbanCCD-UChicago / aot-client-py

The Official Python Client to the Array of Things API
https://api.arrayofthings.org/
Other
6 stars 2 forks source link

proj vs proj.data in PagedResponse? #5

Closed seanshahkarami closed 5 years ago

seanshahkarami commented 5 years ago

In the README example:

from aot_client import AotClient

client = AotClient()
projects = client.list_projects()

for page in projects:
    for proj in page:
        print(f'{proj["name"]} is available at /api/projects/{proj["slug"]}')

I still seem to be getting an error:

Traceback (most recent call last):
  File "script.py", line 8, in <module>
    print(f'{proj["name"]} is available at /api/projects/{proj["slug"]}')
TypeError: 'PagedResponse' object is not subscriptable

However, it seems that changing for proj in page to for proj in page.data fixes this. I just wanted to give you all a heads up about this behavior, in case its just a small mistake in what's being yielded.