[Solved] Example of getting follower list / JS SDK

Hej I cant figure out how to pull data from a sub category, in this example I want to get the list of followers from a User
Edit.
This is the code is now working for the live channels but I only get [object Object] as response and i cant figure out how to use the limit optional.

  $('#get-follower_list button').click(function() {
  	Twitch.api({ method: 'streams/followed'}, function (error, followlist) {
  		$('#get-follower_list input').val(followlist.streams)
      });
    })

The user in user.display_name in the working example is from the function (error, user). You’re looking for user.streams in your example, though you should probably rename user in your function to be more descriptive of what it contains.

Thanks for the response.
I tried to change it to user.streams but I still get zero data

  $('#get-follower_list button').click(function() {
  	Twitch.api({ method: 'streams/followed' }, function (error, user) {
  		$('#get-follower_list input').val(user.streams);
      });
    })

You did login?

streams/followed requires a user to have logged into the JS SDK in order to fetch this as it returns the logged in user data. No login, no data.

Yes I am logged in
Edit So I found out that he onlyby default returns the online channels but I only get an object as returned value

Parse the object…

user.streams is an object/array containing one or more streams.

You need to iterate.

$('#get-follower_list button').click(function() {
Twitch.api({ method: 'streams/followed' }, function (error, user) {
	console.log(user.streams);
  });
})

Will show you whats going on in your console.

for (var x=0;x<user.streams.length;x++) {
    console.log(user.streams[x];
}

Is a quick n’ dirty iterator.

And yes streams/followed will only returns live streams you follow, if you want ALL channels you follow check this endpoint instead Twitch Docs, Channels a user follows

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