An experimental alternative for elm/http.
See more details in elm/http.
{ method : String
, url : String
, headers : List ( String
, String )
, body : Body
, timeout : Maybe Basics.Float
, allowCookiesFromOtherDomains : Basics.Bool
}
Request
Body
Part
{ request : Req
, problem : Problem a
}
Req with Problem
Similar to Http.Error
but have more informarion
init : String -> String -> Req
Arbitrary method
get : String -> Req
GET
post : String -> Req
POST
put : String -> Req
PUT
patch : String -> Req
PATCH
delete : String -> Req
DELETE
withStringBody : String -> String -> Req -> Req
Add text with mime type.
withJsonBody : Json.Encode.Value -> Req -> Req
Add JSON for POST etc.
withFileBody : File -> Req -> Req
Add file to upload
withBytesBody : String -> Bytes -> Req -> Req
Add bytes with mime type.
withMultipartBody : List Part -> Req -> Req
Add multipart body.
stringPart : String -> String -> Part
String part (key and value)
filePart : String -> File -> Part
String part (key and file)
bytesPart : String -> String -> Bytes -> Part
Bytes part (key and mime and bytes)
withHeader : String -> String -> Req -> Req
Add header
withTimeout : Basics.Float -> Req -> Req
Add timeout
allowCookiesFromOtherDomains : Basics.Bool -> Req -> Req
Allow cookies from other domains.
stringCompatible : Req -> Task Http.Error String
Make a task that returns a string or Http.Error
string : Req -> Task (Error String) String
Make a task that returns a string or Req.Error
stringWithError : (Http.Metadata -> Json.Decode.Decoder e) -> Req -> Task (Error e) String
Make a task that returns a string or Req.Error
with custom error.
Decoding errors will be a BadBody
error.
Note: This function assumes the error is always a JSON.
If you are not sure, use string
instead and decode the body later.
jsonCompatible : Json.Decode.Decoder a -> Req -> Task Http.Error a
Make a task that returns an arbitrary data or Http.Error
json : Json.Decode.Decoder a -> Req -> Task (Error String) a
Make a task that returns an arbitrary data or Req.Error
jsonWithError : { decoder : Json.Decode.Decoder a, errorDecoder : Http.Metadata -> Json.Decode.Decoder e } -> Req -> Task (Error e) a
Make a task that returns an arbitrary data or Req.Error
with custom error.
Decoding errors will be a BadBody
error.
Note: This function assumes the error is always a JSON.
If you are not sure, use json
instead and decode the body later.
bytesCompatible : Bytes.Decode.Decoder a -> Req -> Task Http.Error a
Make a task that returns an arbitrary data or Http.Error
.
bytes : Bytes.Decode.Decoder a -> Req -> Task (Error String) a
Make a task that returns an arbitrary data or Req.Error
.
bytesWithError : { decoder : Bytes.Decode.Decoder a, errorDecoder : Http.Metadata -> Bytes.Decode.Decoder e } -> Req -> Task (Error e) a
Make a task that returns an arbitrary data or Req.Error
with custom error.
whatever : msg -> Req -> Task x msg
Ignore the result.
toTask : Http.Resolver x a -> Req -> Task x a
Create a task with existing Http.Resolver
.
trackStringCompatible : String -> (Result Http.Error String -> msg) -> Req -> Platform.Cmd.Cmd msg
Send a request for tracking, expecting a string or Http.Error
.
trackString : String -> (Result (Error String) String -> msg) -> Req -> Platform.Cmd.Cmd msg
Send a request for tracking, expecting a string or Req.Error
.
trackStringWithError : String -> (Result (Error e) String -> msg) -> (Http.Metadata -> Json.Decode.Decoder e) -> Req -> Platform.Cmd.Cmd msg
Send a request for tracking, expecting a string or Req.Error
with custom error.
Decoding errors will be a BadBody
error.
Note: This function assumes the error is always a JSON.
If you are not sure, use trackString
instead and decode the body later.
trackJsonCompatible : String -> (Result Http.Error a -> msg) -> Json.Decode.Decoder a -> Req -> Platform.Cmd.Cmd msg
Send a request for tracking, expecting an arbitrary data or Http.Error
.
trackJson : String -> (Result (Error String) a -> msg) -> Json.Decode.Decoder a -> Req -> Platform.Cmd.Cmd msg
Send a request for tracking, expecting an arbitrary data or Req.Error
.
trackJsonWithError : String -> (Result (Error e) a -> msg) -> { decoder : Json.Decode.Decoder a, errorDecoder : Http.Metadata -> Json.Decode.Decoder e } -> Req -> Platform.Cmd.Cmd msg
Send a request for tracking, expecting an arbitrary data or Req.Error
with custom error.
Decoding errors will be a BadBody
error.
Note: This function assumes the error is always a JSON.
If you are not sure, use trackJson
instead and decode the body later.
trackBytesCompatible : String -> (Result Http.Error a -> msg) -> Bytes.Decode.Decoder a -> Req -> Platform.Cmd.Cmd msg
Send a request for tracking, expecting an arbitrary data or Http.Error
.
trackBytes : String -> (Result (Error String) a -> msg) -> Bytes.Decode.Decoder a -> Req -> Platform.Cmd.Cmd msg
Send a request for tracking, expecting an arbitrary data or Req.Error
.
trackBytesWithError : String -> (Result (Error e) a -> msg) -> { decoder : Bytes.Decode.Decoder a, errorDecoder : Http.Metadata -> Bytes.Decode.Decoder e } -> Req -> Platform.Cmd.Cmd msg
Send a request for tracking, expecting an arbitrary data or Req.Error
with custom error.
trackWhatever : String -> (Result x () -> msg) -> Req -> Platform.Cmd.Cmd msg
Track something but ignore the result.
track : String -> Http.Expect msg -> Req -> Platform.Cmd.Cmd msg
Make a Cmd with tracker using existing Http.Expect
.