Req.encode
You're seeing just the function
encode
, go back to Req module for more information.
Encodes the request body based on its shape.
If body is of the following shape, it's encoded and its content-type
set
accordingly. Otherwise it's unchanged.
Shape | Encoder | Content-Type |
---|---|---|
{:form, data} | URI.encode_query/1 | "application/x-www-form-urlencoded" |
{:json, data} | Jason.encode_to_iodata!/1 | "application/json" |
Examples
iex> Req.post!("https://httpbin.org/post", {:form, comments: "hello!"}).body["form"]
%{"comments" => "hello!"}