How can I select only certain parts of the array?

Hello, I made a query and the answers are back as follows. I just want followers to come back. How can I do that? Using tmi.js client.api method
Responses:{
mature: false,
status: ‘status test’,
broadcaster_language: ‘country’,
broadcaster_software: ‘unknown_rtmp’,
display_name: ‘abc2323’,
game: ‘Just Chatting’,
language: ‘country’,
_id: user-id’,
followers: 124930
}
My Code : https://throwbin.io/78Ke1bJ

client.api({
    url: "https://api.twitch.tv/kraken/channels/userid",
    method: "GET",
    headers: {
        "Accept": "application/vnd.twitchtv.v5+json",
        "Authorization": "oauth:key",
        "Client-ID": "client-id"
    }
}, (err, res, body) => {
    console.log(body.followers);
});
1 Like

OMG! I tried this in many different, irrelevant ways, but it was simply done. Thank you Barry

I copied your code verbatim but worth noting that

"Authorization": "oauth:key",

In API calls, it’s

For Kraken

    "Accept": "application/vnd.twitchtv.v5+json",
    "Authorization": "OAuth YourKey",
    "Client-ID": "client-id"

For helix (different pre word and no v5 header)

    "Authorization": "Bearer YourKey",
    "Client-ID": "client-id"

And I’m not sure if oauth:key is a placeholder or actually what you wrote

After querying, I want to print the value of return followers with chate client.say !followers are written. How can I do that? and Thank you for the sections you mentioned in your previous answer. I will edit

No idea I don’t use tmi.js you’d be better off reading their documentation.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.