JustinLove / elm-twitch-api / Twitch.Helix.Request

Helpers for sending Http requests to the Twitch Helix ("new Twitch API") endpoints.

Send a Request

send : { clientId : String, auth : String, decoder : Json.Decode.Decoder a, tagger : Result Http.Error a -> msg, url : String } -> Platform.Cmd.Cmd msg

Send a basic request to the Twitch Helix ("new Twitch API") endpoints. Lightweight wrapper around Http, so you can go back to basics if something else is needed. Auth is a token received from an oauth loop.

fetchUserByNameUrl : String -> String
fetchUserByNameUrl login =
  "https://api.twitch.tv/helix/users?login=" ++ login

fetchUserByName : String -> String -> Cmd Msg
fetchUserByName auth login =
  Twitch.Helix.Request.send <|
    { clientId = TwitchId.clientId
    , auth = auth
    , decoder = Twitch.Helix.Decode.users
    , tagger = User
    , url = (fetchUserByNameUrl login)
    }

Header Helpers

Useful if you need to make your own Http call with additional headers.

twitchHeaders : String -> String -> List Http.Header

Creates the client-id and outh headers.

Twitch.Helix.twitchHeaders clientId auth