MwitaMike

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

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.

kokolegorille

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?

Where Next?

Popular in Questions Top

JDanielMartinez
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
pmjoe
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
LegitStack
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
openscript
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
vertexbuffer
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
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
alice
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
baxterw3b
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
wernerlaude
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
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New

Other popular topics Top

Brian
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
albydarned
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
lk-geimfari
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
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
danschultzer
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...
548 27727 240
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New
lucidguppy
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
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New
siddhant3030
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

We're in Beta

About us Mission Statement