3HTTP requests for Elm on LynxJS. Replaces XMLHttpRequest with the Fetch API and AbortController.
13 "lynxjs-elm/http": "1.0.0"
47 , headers : List Header
51 , timeout : Maybe Float
52 , tracker : Maybe String
57Full-control request. `timeout` is in milliseconds. `tracker` enables cancellation via `cancel`.
64header : String -> String -> Header
73stringBody : String -> String -> Body -- MIME type, content
74jsonBody : Json.Value -> Body
75bytesBody : String -> Bytes -> Body -- MIME type, bytes
76fileBody : File -> Body
77multipartBody : List Part -> Body
83stringPart : String -> String -> Part -- name, value
84filePart : String -> File -> Part -- name, file
85bytesPart : String -> String -> Bytes -> Part -- name, MIME type, bytes
95expectString : (Result Error String -> msg) -> Expect msg
96expectJson : (Result Error a -> msg) -> Json.Decoder a -> Expect msg
97expectBytes : (Result Error a -> msg) -> Bytes.Decoder a -> Expect msg
98expectWhatever : (Result Error () -> msg) -> Expect msg
101For custom error handling:
104expectStringResponse : (Result x a -> msg) -> (Response String -> Result x a) -> Expect msg
105expectBytesResponse : (Result x a -> msg) -> (Response Bytes -> Result x a) -> Expect msg
124 | BadStatus_ Metadata body
125 | GoodStatus_ Metadata body
132 , statusText : String
133 , headers : Dict String String
140track : String -> (Progress -> msg) -> Sub msg
143Subscribe to progress updates for a tracked request. Note: the Fetch API has limited progress support — tracking primarily enables cancellation.
147 = Sending { sent : Int, size : Int }
148 | Receiving { received : Int, size : Maybe Int }
150fractionSent : { sent : Int, size : Int } -> Float
151fractionReceived : { received : Int, size : Maybe Int } -> Float
155cancel : String -> Cmd msg
158Cancel a tracked request by its tracker name. Uses AbortController under the hood.
165 , headers : List Header
168 , resolver : Resolver x a
169 , timeout : Maybe Float
177stringResolver : (Response String -> Result x a) -> Resolver x a
178bytesResolver : (Response Bytes -> Result x a) -> Resolver x a
184riskyRequest : { ... } -> Cmd msg
185riskyTask : { ... } -> Task x a
188Same as `request`/`task` but allows cookies from other domains (CORS credentials).
194import Json.Decode as D
197 = GotQuote (Result Http.Error String)
202 { url = "https://api.example.com/quote"
203 , expect = Http.expectJson GotQuote (D.field "quote" D.string)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list