Skip to content

Commit 7eb6599

Browse files
authored
fix: try and decode json, returning None if invalid (#7)
1 parent a1cba01 commit 7eb6599

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

knockapi/client.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,13 @@ def request(self, method, endpoint, payload=None):
2323
headers=self.headers,
2424
)
2525

26+
# If we got a successful response, then attempt to deserialize as JSON
2627
if r.ok:
27-
return r.json()
28+
try:
29+
return r.json()
30+
except ValueError:
31+
return None
32+
2833
return r.raise_for_status()
2934

3035

0 commit comments

Comments
 (0)