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 , confirmAction
, fetchClaimsOf , fetchClaimsOf
, fetchLoot , fetchLoot
, fetchSession
, replaceShopItems , replaceShopItems
) )
@@ -420,29 +421,23 @@ replaceShopItems toMsg loot =
} }
-- This is where the error happened
fetchSession toMsg = fetchSession toMsg =
let let
toSession : Result Http.Error String -> msg gotResponse r =
toSession response = case Debug.log "got session:" r of
case Debug.log "got session:" response of
Ok value ->
if value == "admin" then
toMsg Nothing
else
case value of
Ok player -> Ok player ->
toMsg <| Just player toMsg (Just player)
Err _ ->
toMsg Nothing
Err _ -> Err _ ->
toMsg Nothing toMsg Nothing
in in
Http.get Http.get
{ url = "http://localhost:8088/session" { 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) module Session exposing (Session, User(..), getSession, init, key, user)
import Api exposing (valueDecoder) import Api
import Api.Player as Player exposing (Player) import Api.Player as Player exposing (Player)
import Browser.Navigation as Nav import Browser.Navigation as Nav
import Http import Http