prikhi/http-tasks/1.0.0

Http.Tasks

Convenience functions for working with HTTP requests as Tasks.

Requests

get :
{ url : String
, resolver : Resolver x a
}
-> Task x a

Create a GET request.

You can use functions like resolveString and resolveJson to interpret the response in different ways.

{ url : String
, resolver : Resolver x a
, body : Body
}
-> Task x a

Create a POST request.

Resolvers

resolveString : Resolver Error String

Expect the response body to be a String.

resolveJson : Decoder a -> Resolver Error a

Expect the response body to be JSON. Returns a BadBody error when JSON decoding fails.

resolveWhatever : Resolver Error ()

Expect the response body to be anything, and the ignore it.

customResolver : (String -> Result String a) -> Resolver Error a

Use your own body parsing function to build a resolver.