Question

I'm still new to Ruby and trying to use the HTTParty gem to help me write an API Wrapper. I feed HTTParty::get a URI and it parses JSON data. From a quick glance and the way the returned result behaves, it looks like a Hash, but is it? I can't seem to find information online. Another post on StackOverflow shows to use HTTParty::get(...).parsed_response to get the Hash, but this seems outdated.

Was it helpful?

Solution

Do this in the console:

>require 'httparty'
 => true
> response = HTTParty.get( "..." )
 ....
> response.class
 => HTTParty::Response

So the response from HTTParty.get is an HTTParty::Response object.

See this blogpost titled "It's Time To HTTParty!" to learn more about how to work this response.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top