Skip to content

Commit

Permalink
Merge pull request #264 from mattdrewitt/fix-play-pause-invalid-json
Browse files Browse the repository at this point in the history
Fix issue that has popped up with play/pause
  • Loading branch information
guilhermesad authored Sep 6, 2024
2 parents 577fcf7 + 0b7e611 commit b41848f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/rspotify/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ def send_request(verb, path, *params)
end

return response if raw_response
JSON.parse(response) unless response.nil? || response.empty?

begin
JSON.parse(response) unless response.nil? || response.empty?
rescue JSON::ParserError, TypeError => e
response.to_s # Fall back to raw body when the response is not actually a valid JSON response
end
end

# Added this method for testing
Expand Down

0 comments on commit b41848f

Please sign in to comment.