made it work again
This commit is contained in:
23
src/Api.elm
23
src/Api.elm
@@ -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
|
||||
gotResponse r =
|
||||
case Debug.log "got session:" r of
|
||||
Ok player ->
|
||||
toMsg <| Just player
|
||||
|
||||
Err _ ->
|
||||
toMsg Nothing
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user