You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want get all my followers list but i get only the first 50 results... after that i get this error
(node:8088) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'username' of undefined
at C:\Users\ducaa\Desktop\pupp\test.js:32:51
at emitUnhandledRejectionWarning (internal/process/promises.js:168:15)
at processPromiseRejections (internal/process/promises.js:247:11)
at processTicksAndRejections (internal/process/task_queues.js:94:32)
(node:8088) TypeError: Cannot read property 'username' of undefined
at C:\Users\ducaa\Desktop\pupp\test.js:32:51
(node:8088) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
at emitDeprecationWarning (internal/process/promises.js:180:11)
at processPromiseRejections (internal/process/promises.js:249:13)
at processTicksAndRejections (internal/process/task_queues.js:94:32)
THIS IS THE CODE
const userprompt = await prompts(questions);
var username = userprompt['username'];
var password = userprompt['password'];
const client = new Instagram({ username, password });
await client.login();
const delay = ms => new Promise(resolve => setTimeout(resolve, ms))
const userdata = await client.getUserByUsername({ username: client.credentials.username });
var myuserid = userdata['id'];
var myfollowerscount = userdata['edge_followed_by']['count'];
console.log('Count My Followers : '+myfollowerscount);
const myfollowers = await client.getFollowers({ userId: myuserid, first: myfollowerscount });
var numb = 0;
while(numb < myfollowerscount){
console.log(numb+1, myfollowers.data[numb]['username']);
if(numb > 35){
await delay(4000);
}
numb++;
}
console.log('secondpart');
The text was updated successfully, but these errors were encountered:
Hey,
You have a variable has_next_page that inform you if you can change your page to end_cursor (next page of follower).
The first parameters is limited to 50, it's the number of followers per pages.
Here it is a sinple code to list all your followers :
(async()=>{//List of all Followers NameletmyFollowers=[]letmyId="myUserId"letfollowers=awaitclient.getFollowers({userId: myId})//get your followers on the first pageletnextPage=followers.page_info.has_next_page//true if you have an other page of followersletcursor=followers.page_info.end_cursor//next page of followeraddFollowersName(followers.data)//loop to navigate into all the pages of followerswhile(nextPage){followers=awaitclient.getFollowers({userId: id,first: 50,after: cursor})nextPage=followers.page_info.has_next_pagecursor=followers.page_info.end_cursoraddFollowersName(followers.data)}console.log(`List of all my Followers : ${myFollowers.join("\n- ")}`)})
I want get all my followers list but i get only the first 50 results... after that i get this error
(node:8088) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'username' of undefined
at C:\Users\ducaa\Desktop\pupp\test.js:32:51
at emitUnhandledRejectionWarning (internal/process/promises.js:168:15)
at processPromiseRejections (internal/process/promises.js:247:11)
at processTicksAndRejections (internal/process/task_queues.js:94:32)
(node:8088) TypeError: Cannot read property 'username' of undefined
at C:\Users\ducaa\Desktop\pupp\test.js:32:51
(node:8088) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
at emitDeprecationWarning (internal/process/promises.js:180:11)
at processPromiseRejections (internal/process/promises.js:249:13)
at processTicksAndRejections (internal/process/task_queues.js:94:32)
THIS IS THE CODE
The text was updated successfully, but these errors were encountered: