Skip to content

Instantly share code, notes, and snippets.

@jzxhuang
Last active April 5, 2019 03:45
Show Gist options
  • Save jzxhuang/5fdf8b2f6eb37a52657647bfbe3101bb to your computer and use it in GitHub Desktop.
Save jzxhuang/5fdf8b2f6eb37a52657647bfbe3101bb to your computer and use it in GitHub Desktop.
Convert a string Http.Response to a Tuple (Http.Metadata, String)
convertResponseString : Response String -> Result Error ( Metadata, String )
convertResponseString httpResponse =
case httpResponse of
Http.BadUrl_ url ->
Err (Http.BadUrl url)
Http.Timeout_ ->
Err Http.Timeout
Http.NetworkError_ ->
Err Http.NetworkError
Http.BadStatus_ metadata body ->
Err (Http.BadStatus metadata.statusCode)
Http.GoodStatus_ metadata body ->
Ok ( metadata, body )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment