2020-03-04 19:17:06 +03:00
|
|
|
module PagesHttp exposing (..)
|
|
|
|
|
2021-04-02 23:59:07 +03:00
|
|
|
import Http exposing (Response(..))
|
2020-03-04 19:17:06 +03:00
|
|
|
import Pages.Http exposing (..)
|
|
|
|
import SimulatedEffect.Http as Http
|
|
|
|
|
|
|
|
|
2021-04-03 00:44:40 +03:00
|
|
|
expectString : (Result Error String -> msg) -> Http.Expect msg
|
2020-03-04 19:17:06 +03:00
|
|
|
expectString toMsg =
|
|
|
|
Http.expectStringResponse toMsg <|
|
|
|
|
\response ->
|
|
|
|
case response of
|
|
|
|
BadUrl_ url ->
|
|
|
|
Err (BadUrl url)
|
|
|
|
|
|
|
|
Timeout_ ->
|
|
|
|
Err Timeout
|
|
|
|
|
|
|
|
NetworkError_ ->
|
|
|
|
Err NetworkError
|
|
|
|
|
|
|
|
BadStatus_ metadata body ->
|
|
|
|
Err (BadStatus metadata body)
|
|
|
|
|
2021-04-03 00:44:40 +03:00
|
|
|
GoodStatus_ _ body ->
|
2020-03-04 19:17:06 +03:00
|
|
|
Ok body
|