Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GET request parameters are never generated! #74

Open
elitepleb opened this issue Feb 3, 2022 · 1 comment
Open

GET request parameters are never generated! #74

elitepleb opened this issue Feb 3, 2022 · 1 comment

Comments

@elitepleb
Copy link

There's a major oversight in this library, GET request parameters are never generated!
For instance calling Lurker.statuses(conn, user_id, [max_id: post_id] ) will never generate a request with max_id set.

URL parameters with HTTPoison can be passed in two ways:

  • via setting :params in HTTPoison.Request and request/1.
  • by passing parameters in options = [params: [max_id: post_id]] via request/5

https://hexdocs.pm/httpoison/HTTPoison.Request.html#content

This library does neither.
It always JSON encodes options and passes them into the body as with :post requests, since the options passed are Config.http_options() by default and request/1 is never used.

This leaves :get 14 api's with options silently dysfunctional, making for quite a headache.
I'm quite surprised no one has yet to catch this misbehavior.

There ought to be a nicer solution than sticking

    options =
      Config.http_options() ++
        if method == :get do
          [params: payload]
        else
          []
        end

in Hunter.Api.HTTPClient.request! and

    body =
      if http_method != :get do
        process_request_body(data)
      else
        ""
      end

in Lurker.Api.Request.request

But it works for now, and other things are waiting to get finished first.

@milmazz
Copy link
Owner

milmazz commented Feb 13, 2022

@elitepleb Thanks for the report. PRs are more than welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants