Hi,
no matter which api i access through hackney i get responses like this:"{\"kind\":\"analytics#gaData\",\"id\":...
{ok, status, response, body} = :hackney.get(url, [],[], [with_body: true] )
What can i do to get a json i can access?
thanks
Hi,
no matter which api i access through hackney i get responses like this:"{\"kind\":\"analytics#gaData\",\"id\":...
{ok, status, response, body} = :hackney.get(url, [],[], [with_body: true] )
What can i do to get a json i can access?
thanks
You need to use a JSON parser. The most popular one is poison.
You’d commonly see something like that in the code around the hackney calls:
case :hackney.get(url, [],[], [:with_body]) do
{:ok, status, _headers, body} when status in 200..299 ->
{:ok, Poison.decode!(body)}
{:ok, status, headers, body} ->
# we got some other http status, make it an error
{:error, {:request, status, headers, body}}
{:error, reason} ->
# there was some other error, e.g. server is not available
{:error, {:network, reason}}
end