Releases: lukewestby/elm-http-extra
Add withJsonBody
Thanks to @ento!
params = Json.Encode.object
[ ("sortBy", Json.Encode.string "coolness")
, ("take", Json.Encode.int 10)
]
post "https://example.com/api/items/1"
|> withHeader "Content-Type" "application/json"
|> withJsonBody params
Add withUrlEncodedBody
Thanks to @Istar-Eldritch for this contribution!
Flexible body readers
See http://lukewestby.com/post/release-elm-http-extra-5-0-0/ for the announcement and reasons for the changes!
Thanks to @fredcy and @mgold for their input leading to these changes!
Forgot to expose members of Error!
Oops. Good thing version numbers are free!
Update to README
Adds changes to send
to README example
Better errors and responses!
Modifies send to accept decoders for both 2xx and non-2xx response bodies.
Adds a custom response type for which send returns a task that looks like:
type alias Response a =
{ data : a
, status : Int
, statusText : String
, headers : Dict String String
, url : String
}
and introduces a new error type which will pass through a Response a in the case of non-2xx results:
type Error a
= Timeout
| UnexpectedPayload String
| NetworkError
| BadRequest (Response a)
This way you get built-in JSON decoding as well as response information for failed requests.
You can use this without installing elm-http explicitly now!
Re-exported a number of useful things from Http
to allow folks to use this package without also importing Http
. This includes Http.Error
, Http.Request
, Http.Settings
, Http.url
, as well as a new body function withMutlipartStringBody
that allows key-value pair multipart bodies to be constructed automatically from List (String, String)
inputs.
README typo fix
Corrects import statement in exampe
README changes that need to get into package.elm-lang.org
1.2.1 patch version bump so we can get the README updates onto the registry
Add introspection functions
Adds:
toRequest
toSettings