trot icon indicating copy to clipboard operation
trot copied to clipboard

Documentation on how to fetch request body data

Open E14 opened this issue 7 years ago • 1 comments

Documentation on the intended way on how to fetch the request body data for PUT/POST/... requests is missing.

put "/" do
    IO.puts(inspect(conn.body_params))
    ""
end

# Prints:
# %Plug.Conn.Unfetched{aspect: :body_params}

E14 avatar Feb 09 '18 17:02 E14

I found out in the meantime - you're supposed to do this through the config:

eg.

config :trot, :pre_routing, [   
        # other plugs...
	"Elixir.Plug.Parsers": [parsers: [:json], json_decoder: Poison],
]

E14 avatar Feb 22 '18 17:02 E14