simonh1000/elm-jwt/7.1.0

NOTE: the latest version is 7.1.1

Jwt.Http

Authenticated Http requests

get :
String
-> { url : String
, expect : Expect msg
}
-> Cmd msg

A replacement for Http.get that also takes a token, which is attached to the headers.

getData : String -> Cmd Msg
getData token =
    Jwt.Http.get token
        { url = serverUrl ++ "/api/data"
        , expect = Http.expectJson OnDataResponse dataDecoder
        }
String
-> { url : String
, body : Body
, expect : Expect msg
}
-> Cmd msg

A replacement for Http.post that also takes a token, which is attached to the headers. NOTE that is important to use jsonBody to ensure that the 'application/json' is added to the headers

sendToServer : String -> String -> Json.Decode.Decoder a -> Json.Encode.Value -> Cmd msg
sendToServer token url dec value =
    Jwt.Http.post token
        { url = url
        , body = Http.jsonBody value
        , expect = Http.expectJson ContentResult (phoenixDecoder dec)
        }
put :
String
-> { url : String
, body : Body
, expect : Expect msg
}
-> Cmd msg

Create a PUT command with a token attached to the headers.

String
-> { url : String
, expect : Expect msg
}
-> Cmd msg

Create a DELETE command with a token attached to the headers.

is401 : Error -> Bool

Helper that checks an Http.Error for a 401