Add error checking
This commit is contained in:
parent
81d8f1f892
commit
135f8d0b65
@ -13,6 +13,9 @@ def getRecentDiscussion():
|
||||
recent = {"title": "N/A", "link": "#"}
|
||||
obj = python_requests.get("https://talk.zhdo.space/api/recent/posts/week")
|
||||
if obj.status_code == 200:
|
||||
if not obj.json():
|
||||
return recent
|
||||
else:
|
||||
recent["title"] = str(obj.json()[0]["topic"]["title"])
|
||||
recent["link"] = discussionPrefix + str(obj.json()[0]["topic"]["slug"])
|
||||
return recent
|
||||
|
Loading…
Reference in New Issue
Block a user