Skip to content

Commit

Permalink
fix case of empty response
Browse files Browse the repository at this point in the history
  • Loading branch information
rintaro committed Mar 25, 2018
1 parent 89e14ab commit e7e600a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pybitflyer/async.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,16 @@ async def request(self, endpoint, method="GET", params=None):
try:
if method == 'GET':
async with s.get(url, params=params, timeout=self.timeout, headers=header) as r:
contents_json = await r.json()
return contents_json
contents = await r.text()
if len(contents) > 0:
contents = json.loads(contents)
return contents
else: # method == "POST":
async with s.post(url, data=json.dumps(params), timeout=self.timeout, headers=header) as r:
contents_json = await r.json()
return contents_json
contents = await r.text()
if len(contents) > 0:
contents = json.loads(contents)
return contents
except Exception as e:
print(e)
raise e

0 comments on commit e7e600a

Please sign in to comment.