This repository has been archived by the owner on Oct 1, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
200 additions
and
340 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module Remote exposing (..) | ||
|
||
import Http | ||
import Messages exposing (..) | ||
import Models exposing (..) | ||
import Json.Decode as Decode | ||
|
||
|
||
fetchData : String -> Cmd Msg | ||
fetchData dataUrl = | ||
makeRequest dataUrl | ||
|> Http.send ReceiveRawResp | ||
|
||
|
||
makeRequest : String -> Http.Request RawResponse | ||
makeRequest dataUrl = | ||
Http.request | ||
{ method = "GET" | ||
, headers = | ||
[ Http.header "Accept" "application/json" ] | ||
, url = dataUrl | ||
, body = Http.emptyBody | ||
, expect = | ||
Http.expectStringResponse (\resp -> Ok (extractRawResponse resp)) | ||
, timeout = Nothing | ||
, withCredentials = True | ||
} | ||
|
||
|
||
extractRawResponse : Http.Response String -> RawResponse | ||
extractRawResponse resp = | ||
{ body = resp.body | ||
, next = nextFromBody resp.body | ||
} | ||
|
||
|
||
nextFromBody : String -> Maybe String | ||
nextFromBody body = | ||
body | ||
|> Decode.decodeString (Decode.field "next" (Decode.maybe Decode.string)) | ||
|> Result.withDefault Nothing |
Oops, something went wrong.