Skip to content

Commit

Permalink
fix(http): handle non-object responses
Browse files Browse the repository at this point in the history
  • Loading branch information
ProGM committed Sep 29, 2023
1 parent d6377fb commit 8d49467
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/any_query/adapters/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,16 @@ def run_http_request(endpoint, url, params)

raise response.inspect unless response.success?

if response.parsed_response.is_a?(Array)
response.parsed_response.map(&:deep_symbolize_keys)
symbolize_keys(response.parsed_response)
end

def symbolize_keys(response)
if response.is_a?(Array)
response.map do |item|
symbolize_keys(item)
end
else
response.parsed_response&.deep_symbolize_keys
response.respond_to?(:deep_symbolize_keys) ? response&.deep_symbolize_keys : response
end
end

Expand Down

0 comments on commit 8d49467

Please sign in to comment.