Skip to content

Commit

Permalink
Do not try to parse response if status is 204
Browse files Browse the repository at this point in the history
Because 204 means there is no content. The json_decode function throws error with empty string.
  • Loading branch information
egesu authored May 30, 2024
1 parent c8d9b9b commit 61f73a3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Http/GuzzleHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ private function tokenIsExpired(): bool
*/
private function parseResponse(ResponseInterface $response): array
{
if ($response->getStatusCode() === 204) {
return [];
}

try {
return (array) json_decode((string) $response->getBody(), true, 512, JSON_THROW_ON_ERROR);
} catch (JsonException $e) {
Expand Down

0 comments on commit 61f73a3

Please sign in to comment.