thedist/Twitch_API_v5

api.channels.channelByID returns undefined

smashboy opened this issue · 0 comments

Im getting channelID from api.streams.live and passing res.streams.channel._id to
api.channels.channelByID in result Im getting undefined.
When Im just use get request in browser like this for example https://api.twitch.tv/kraken/channels/190835892?client_id=XXXX
It Returns {"error":"Not Found","status":404,"message":"Unable to find channel for login \"190835892\""}
But when im insert channel login https://api.twitch.tv/kraken/channels/lirik?client_id=XXXX
Im finally receiving the channel info.
So I tried to pass login not channel id into api.channels.channelByID and I get error
GET https://api.twitch.tv/kraken/channels/welovegames?client_id=XXXX 400 ()
But this get request actually work in browser but not in Twitch_API_v5
So the problem is that I cant receive any data from api.channels.channelByID
This is my code:
Try to get by channelId:

this.props.api.streams.live({limit: limit}, (err, res) => {
                if (err) {
                    this.setState({streamsList: null})
                    this.setState({streamsListError: true})
                } else {
                    this.setState({streamsList: res.streams})
                    console.log(res.streams[0].channel._id)
                    let channelId = res.streams[0].channel._id
                    this.props.api.channels.channelByID({channelID: channelId}, (err, res) => {
                        if (err) {
                            console.log(err)
                        } else {
                            console.log(res.stream)
                        }
                    })
                }
})

By channel login:

this.props.api.streams.live({limit: limit}, (err, res) => {
                if (err) {
                    this.setState({streamsList: null})
                    this.setState({streamsListError: true})
                } else {
                    this.setState({streamsList: res.streams})
                    console.log(res.streams[0].channel._id)
                    let channelId = res.streams[0].channel._id
                    this.props.api.channels.channelByID({channelID: "lirik?client_id=XXXX"}, (err, res) => {
                        if (err) {
                            console.log(err)
                        } else {
                            console.log(res.stream)
                        }
                    })
                }
})