Elixir (3.8+)


Last year I fell in love with Elixir, so I don’t want to miss a small sample using it. I’m running Elixir 1.12.2 on my machine. Check your installation by printing the version.

(base) ~ % elixir --version
Erlang/OTP 24 [erts-12.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [jit] [dtrace]

Elixir 1.12.2 (compiled with Erlang/OTP 24)

No Elixir running on your system? You really should give it a try. Go here to learn how to install it on your operating systems.

Plain request

Since Elixir 1.12. Elixir supports Elixir-scripts so we can make use of that to quickly install a small library that we use in favor to erlangs httpc and fire a request to finally print the result like so:

 { :req, "~> 0.2" }

response = Req.get!("https://api.football-data.org/v4/competitions")
competitions = response.body["competitions"]
Enum.map(competitions, &(IO.inspect(&1["name"])))