made it work again

This commit is contained in:
2019-11-27 22:02:47 +01:00
parent c52fea683d
commit c50cb37900
2 changed files with 11 additions and 16 deletions

View File

@@ -12,6 +12,7 @@ module Api exposing
, confirmAction
, fetchClaimsOf
, fetchLoot
, fetchSession
, replaceShopItems
)
@@ -420,29 +421,23 @@ replaceShopItems toMsg loot =
}
-- This is where the error happened
fetchSession toMsg =
let
toSession : Result Http.Error String -> msg
toSession response =
case Debug.log "got session:" response of
Ok value ->
if value == "admin" then
toMsg Nothing
else
case value of
Ok player ->
toMsg <| Just player
Err _ ->
toMsg Nothing
gotResponse r =
case Debug.log "got session:" r of
Ok player ->
toMsg (Just player)
Err _ ->
toMsg Nothing
in
Http.get
{ url = "http://localhost:8088/session"
, expect = Http.expectJson toSession (valueDecoder Api.Player.playerDecoder)
, expect = Http.expectJson gotResponse Api.Player.playerDecoder
}

View File

@@ -1,6 +1,6 @@
module Session exposing (Session, User(..), getSession, init, key, user)
import Api exposing (valueDecoder)
import Api
import Api.Player as Player exposing (Player)
import Browser.Navigation as Nav
import Http