Skip to content

Commit

Permalink
Merge pull request #52 from warlof/fix-json-decode
Browse files Browse the repository at this point in the history
fix decode error due to empty content
  • Loading branch information
cryptiklemur committed Jun 7, 2018
2 parents 849b785 + 2cf9a3a commit 88d34fa
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/DiscordClient.php
Expand Up @@ -225,7 +225,12 @@ private function convertResponseToResult(
}
}

$data = json_decode($response->getBody()->__toString());
// attempt to deserialize into JSON only if there is a content in the response
$data = null;
if ($response->getStatusCode() !== 204) {
$data = json_decode($response->getBody()->__toString());
}

$array = strpos($operation['responseTypes'][0]['type'], 'Array') !== false;
$responseType = $operation['responseTypes'][0]['type'];
if ($array) {
Expand Down

0 comments on commit 88d34fa

Please sign in to comment.