Reputation: 19398
I am trying to write simple app using Elixir language. HTTPoison.get!
returns HTTPoison.Response
structure with body
key. Is it possible to include this logic to pipeline?
Repo.one(Site).sitemap_url
|> HTTPoison.get!
|> ...
|> Floki.find("sitemap loc")
|> Enum.map(fn(element) -> Floki.text(element) end)
Upvotes: 1
Views: 788
Reputation: 1637
As explained here, structs are just maps. Hence, you can use the functions from the Map
module, including Map.get
to extract keys:
Repo.one(Site).sitemap_url
|> HTTPoison.get!
|> Map.get(:body)
|> Floki.find("sitemap loc")
|> Enum.map(fn(element) -> Floki.text(element) end)
Upvotes: 1