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 2ada76d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pybitflyer/async.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,18 @@ 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
try:
contents = await r.json()
except:
contents = await r.text()
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
try:
contents = await r.json()
except:
contents = await r.text()
return contents
except Exception as e:
print(e)
raise e

0 comments on commit 2ada76d

Please sign in to comment.