correl/elm-paginated/3.0.0

NOTE: this package is not compatible with Elm 0.19.1

Paginated

A library for Facilitates fetching data from a paginated JSON API.

Requests and Responses

type Request a

Encapsulates an API request for a list of items of type a.

get : String -> Decoder a -> Request a

Build a GET request.

post : String -> Body -> Decoder a -> Request a

Build a POST request.

Custom requests

type alias RequestOptions a =
{ method : String
, headers : List Header
, url : String
, body : Body
, decoder : Decoder a
, timeout : Maybe Time
, withCredentials : Bool
}

Describes an API request.

request : RequestOptions a -> Request a

Create a custom request, allowing the specification of HTTP headers and other options. For example:

Paginated.request
    { method = "GET"
    , headers = [Http.header "Private-Token" "XXXXXXXXXXXXXXXX"]
    , url = url
    , body = Http.emptyBody
    , decoder = decoder
    , timeout = Nothing
    , withCredentials = False
    }

Sending requests

send : (Result Error (List a) -> msg) -> Request a -> Cmd msg

Send a Request.

Low-Level operations

toTask : Request a -> Task Error (List a)

Convert a Request into a Task.

This is only really useful if you want to chain together a bunch of requests (or any other tasks) in a single command.