Skip to content

Get request blows up if params is nil #422

@thiagomajesk

Description

@thiagomajesk

Hi! Thanks for this great lib!

Exactly what the title says, the code below will blow up when params is nil:

 Req.get(Req.new([url: "/", params: opts[:query]]))

I think we should probably coalesce it into an empty map or something.

 ** (Protocol.UndefinedError) protocol Enumerable not implemented for nil of type Atom. This protocol is implemented for the following type(s): Date.Range, File.Stream, Function, GenEvent.Stream, HashDict, HashSet, IO.Stream, Jason.OrderedObject, List, Map, MapSet, Range, Req.Response.Async, Stream
stacktrace:
(elixir 1.17.2) lib/enum.ex:1: Enumerable.impl_for!/1
(elixir 1.17.2) lib/enum.ex:166: Enumerable.reduce/3
(elixir 1.17.2) lib/enum.ex:4423: Enum.map_intersperse/3
(elixir 1.17.2) lib/enum.ex:1804: Enum.map_join/3
(req 0.5.6) lib/req/steps.ex:524: Req.Steps.put_params/2
(req 0.5.6) lib/req/request.ex:1087: Req.Request.run_request/1
(req 0.5.6) lib/req/request.ex:1047: Req.Request.run/1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions