0

i create my own browser extension for my twitch channel.

I coded the javascript extension with the Twitch Kraken API but it has been changed.

The new Twitch API is 'https://api.twitch.tv/helix/streams?game_id=33214'

I replaced the API in my code but the extension always displays an ONLINE status.

    xhr.open('GET', this.API_URL_STREAM, true)

    xhr.setRequestHeader('Accept', 'application/vnd.twitchtv.v5+json')
    xhr.setRequestHeader('Client-ID', this.CLIENT_ID)

    xhr.onreadystatechange = e => {
        if (xhr.readyState == 4 && xhr.status == 200) {
            const body = xhr.responseText
            let json = {}

            try {
                json = JSON.parse(body)
            } catch (e) {
                console.info(e, xhr.responseText)
            }

            this.handle_response(json)
        }
    }
    xhr.send(null)
}

I have no error message. Just always an ONLINE status of my stream but i'm not live.

georgeawg
  • 48,608
  • 13
  • 72
  • 95
Julien
  • 1
  • looks like the request itself is ok so no error, but two things missing to help you, first what url is `API_URL_STREAM` and what do you do with the result? – Fusselchen Sep 09 '19 at 05:48
  • API_URL_STREAM is https://api.twitch.tv/helix/streams?game_id=33214 and i make a boolean thing which choose between "offline" or "online" – Julien Sep 09 '19 at 20:23
  • Your URL is for requesting current streams of a specific game. Not for stream status. try https://api.twitch.tv/helix/streams?user_login=YourTwitchName if the data array is empty the stream is offline. – Fusselchen Sep 10 '19 at 12:03

0 Answers0