How to write curl query in elixir

Hi, how can I write the following curl in Elixir?

def get_host_name(), do: {:ok, _hostname} = :inet.gethostname()

def get_info() do
System.cmd("curl", ~w[-X GET http://#{get_host_name()}:6666/info]

I have tried this and it seems to work as well but It takes lots of time to compute. Also, how can I store the result of the curl in form of a map and throw an error if it is not valid JSON?

You might use a normal http client instead of using curl with System.cmd.

Do You know about httpoison, or finch, or any others?


I have tried Httpoison and it worked perfectly :slight_smile:


Yes, it is easier with httpoison.