Skip to content

Commit 11999b3

Browse files
Use resp.json() on async parse response. (#81)
1 parent a5c7269 commit 11999b3

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

stream_chat/async_chat/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ def __init__(self, api_key, api_secret, timeout=6.0, **options):
3737
async def _parse_response(self, response):
3838
text = await response.text()
3939
try:
40-
parsed_result = json.loads(text) if text else {}
41-
except ValueError:
40+
parsed_result = await response.json() if text else {}
41+
except aiohttp.ClientResponseError:
4242
raise StreamAPIException(text, response.status)
4343
if response.status >= 399:
4444
raise StreamAPIException(text, response.status)
@@ -248,7 +248,7 @@ def channel(self, channel_type, channel_id=None, data=None):
248248
return Channel(self, channel_type, channel_id, data)
249249

250250
async def delete_channels(self, cids, **options):
251-
return await self.post(f"channels/delete", data=dict(options, cids=cids))
251+
return await self.post("channels/delete", data=dict(options, cids=cids))
252252

253253
async def list_commands(self):
254254
return await self.get("commands")

stream_chat/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def channel(self, channel_type, channel_id=None, data=None):
244244
return Channel(self, channel_type, channel_id, data)
245245

246246
def delete_channels(self, cids, **options):
247-
return self.post(f"channels/delete", data=dict(options, cids=cids))
247+
return self.post("channels/delete", data=dict(options, cids=cids))
248248

249249
def list_commands(self):
250250
return self.get("commands")

0 commit comments

Comments
 (0)