Closed hrivera2014 closed 6 years ago
I think this may be the solution, but I have not tried it so far.
https://stackoverflow.com/questions/28008897/node-js-twitter-api-cursors
Also I read about how promises can solve the problem but I don't know nothing about promises until now.
I find a solution to the problem thru the link above using recursive call. I just rewrite the code as:
var params = {screen_name: 'someOne',count: '200', cursor: -1};
client.get('friends/list', params, function getlist(error, list, response)
{
if (!error)
{
for (var index=0,index<list.users.length-1,index++)
{
console.log(index);
console.log("Name: " + list.users[index].name);
console.log("Screen name: " + list.users[index].screen_name);
console.log("followers: " + list.users[index].followers_count);
}
if(list.next_cursor != 0)
{
params.cursor = list.next_cursor
client.get('friends/list',params, getlist);
}
}
)};
I wonder why the first element of the next page is the same that the last element in before page. By this strange behavior I put the final argument of the for loop as: list.users.length-1.
Please I need to use cursor parameter to navigate thru pages. How I can get next_cursor from the list object but outside of the client.get Of course, as you can guess, I m not a nodejs expert and I have to study a lot about asynchronous responses I believe. I'm only a researcher struggling with this stuff..