sashaafm / eetf / Eetf.Http

Receive HTTP responses in Erlang's External Term Format.

Expect

expectTerm : (Result Http.Error a -> msg) -> Eetf.Decode.Decoder a -> Http.Expect msg

Expect the response body to be an Erlang term encoded in the External Term Format. This function is meant to be used like the expectString or expectJson functions in the elm/http package:

import Eetf.Decode
import Eetf.Http
import Http

type Msg
  = GotText (Result Http.Error String)

getRandomText : Cmd Msg
getRandomText =
  Http.get
    { url = "https://example.com/texts/123"
    , expect = Eetf.Http.expectTerm GotText Eetf.Decode.string
    }

The response is a sequence of bytes encoded in the External Term Format, but in this case we expect it to be encoded text that can be turned into a String.