Skip to content

Commit

Permalink
fix: Handle missing 'link' header attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
sondrelg committed Feb 12, 2023
1 parent 02b1c7a commit 192ba6d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,13 @@ async def get_all_pages(*, url: str, http_client: AsyncClient) -> list[dict]:
response.raise_for_status()
result.extend(response.json())

rels = {rel: url for url, rel in rel_regex.findall(response.headers['link'])}

await wait_for_rate_limit(response=response)

if link := response.headers.get('link'):
rels = {rel: url for url, rel in rel_regex.findall(link)}
else:
break

return result


Expand Down

0 comments on commit 192ba6d

Please sign in to comment.