diff --git a/target_everyaction/sinks.py b/target_everyaction/sinks.py index 7362ba0..51231bf 100644 --- a/target_everyaction/sinks.py +++ b/target_everyaction/sinks.py @@ -117,9 +117,11 @@ def _get_all_activist_codes(self) -> dict: for item in data["items"]: all_codes[item["name"].lower()] = item["activistCodeId"] - if "nextPageLink" not in data: + # Check if there are more pages + if not data.get("nextPageLink"): break + # Extract next page URL and make request next_page = data["nextPageLink"].split("?")[1] response = self.request_api("GET", endpoint=f"activistCodes?{next_page}") else: