Request example NODEJS

anyone can share him start code nodejs for the new twitch api ?
im beginner and i want to try to dev my own bot, thanks

You jsut need to pick a library that makes cURL requests and away you go.

If using Got, (incomplete sample)

got(
    'https://api.twitch.tv/helix/users??id=44322889',
    {
        headers: {
            'Content-Type': 'application/json',
            'Client-ID': client_id
        },
        gzip: true
    }
)
.then(resp => {
    console.log(resp.body);

Got is documented here

can i update my old code ?

xhr.open(“GET”, “https://api.twitch.tv/kraken/channels/zehnovh/follows?limit=1&client_id=” + config.twitchToken, true);

I’ve never used XHR in a nodeJS server application so yes?

Give you are using kraken

You can either

https://dev.twitch.tv/docs/v5/guides/migration

Upgrade from v3 to v5

Or go to Helix.

For XHR you can refer to this post

Where we covered how to XHR