User data undefined?

res returns an object, that contains the axios response
res.data contains the actual body response

You’ll need to JSON decode it (unless axios did this for you)

var data_response = JSON.parse(res.data);

Then you’ll have the actual API response and can grab the users id from that

var user_id = data_response.data.[0].id;

Get Followed Streams needs the users token with the relevant scope attached to it, so call the users API with no query string params, and it’ll return the object that represents the user

That’ll return the user object for the user whom has logged in, then go and call the Get Followed Streams API, something like this, (not tested)

const getUserURL = `https://api.twitch.tv/helix/users`

    axios({

        method: 'get',

        url: getUserURL,

        headers: {

            'Authorization': 'Bearer ' + auth[clientID].access_token,

            'Client-Id': clientID

        }})

        .then((res) => {

            console.log(res)

            var data_response = JSON.parse(res.data);
            var user_id = data_response.data.[0].id;

            var urltocall = 'https://api.twitch.tv/helix/streams/followed?user_id=' + user_id;
        })

So

  • user logs in to your Tool with the relevant scope attached (user:read:follows)
  • call the Get Users API (with no query string param) to get the user data about the token
  • call the Get Followed Streams API with the userID from the response data