MwitaMike
Unexpected results with HTTPoison
Am new to Elixir ,so am trying to create a function that uses HTTPoison to fetch the link .
The expected output when I call the function is suppose to appear this way:
%HTTPoison.Response{
body: "<!doctype html>...",
headers: [
{"Content-Type", "text/html"},..],
request: %HTTPoison.Request{
body: "",
headers: [],
method: :get,
options: [],
params: %{},
url: "https://medium.."
This is how my code looks like:
def fetch_blog() do
HTTPoison.get!("https://medium.com"
)
t()::%HTTPoison.Response{
body:term(),
headers:list(),
request:HTTPoison.Request.t(),
request_url:HTTpoison.Request.url(),
status_code:integer()
}
end
Where could I have got it wrong please!
Most Liked
NobbZ
This probably causes a syntax error, there is no need to have the typedefinition listed there, you can remove it, such that your function looks like this:
def fetch_blog() do
HTTPoison.get!("https://medium.com")
end
HTTPoison.get!/1s returned value should look exactly like you specified.
3
kokolegorille
Hello and welcome,
Please don’t forget to wrap your code with 3 backticks ``` for better readability. I made the change so You can see the difference.
What is the result, or error when You call your function?
1
Popular in Questions
Hi! May someone helps me, please!
I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
I’m hoping you guys can give me some general advice and perhaps code examples if you’re feeling up to it.
I’m very interested in Elixir,...
New
Hello!
Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
Hey,
Just curious what are the main benefits of Elixir compared to Clojure?
When is Elixir more useful than Clojure and vice versa?
Th...
New
Hi guys, i’m new in the Elixir world, and i have to say, that i love it!
i’m having some problem to understand anonymous functions with ...
New
In AR this is so simple
@articles = current_user.articles
How to do in Ecto?
def index(conn, _params) do
current_user = conn.assig...
New
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum.
...
New
Other popular topics
What is the proper way to load a module from a file in to IEX?
In the python world, doing something like this pretty standard:
from ....
New
Hello all!
I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
What is most correct way to open, read and parse JSON file with poison?
For example if we have example.json file in root of some projec...
New
I would like to know what is the best IDE for elixir development?
New
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch.
This project took far...
New
After calling mix ecto.create I get this error:
17:00:32.162 [error] GenServer #PID<0.412.0> terminating
** (Postgrex.Error) FATAL...
New
I have a super simple question about elixir - how would I take a file like this
foo bar baz
and output a new file that enumerates th...
New
by Lance Halvorsen
Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
New
Hi,
I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New







