Skip to content
This repository was archived by the owner on Sep 8, 2023. It is now read-only.
This repository was archived by the owner on Sep 8, 2023. It is now read-only.

Issue with getUserFollowers method in threads-api version 1.6.3 #286

@a-burlakovv

Description

@a-burlakovv

Hello,

I've been using your threads-api library for a project and I've encountered an issue with the getUserFollowers method. I'm currently using version 1.6.3 of the library.

Here's the script I'm using:

import pkg from 'threads-api';
import fs from 'fs';
const { ThreadsAPI } = pkg;

const threadsAPI = new ThreadsAPI({
  username: 'my_username',
  password: 'my_password',
  deviceID: 'android-2tjieqf5r9w00000'
});

const delay = ms => new Promise(resolve => setTimeout(resolve, ms));

const main = async () => {
  let cursor = null;
  let followers = [];

  const myID = await threadsAPI.getUserIDfromUsername('my_username');

  const { users: myFollowers, next_max_id } = await threadsAPI.getUserFollowers(myID);
  cursor = next_max_id;

  for (const follower of myFollowers.slice(0, 20)) {
    let followerCursor = null;
    let followerFollowers = [];
    do {
      const { users, next_max_id } = await threadsAPI.getUserFollowers(follower.user_id, followerCursor);
      followerFollowers = followerFollowers.concat(users.map(user => user.username));
      followerCursor = next_max_id;

      console.log(`Collected ${followerFollowers.length} followers. Waiting 10 seconds before the next followers request...`);
      await delay(10000);
    } while (followerCursor && followerFollowers.length < 500);

    followers = followers.concat(followerFollowers);
    console.log(`Finished collecting followers for ${follower.username}. Total followers collected: ${followers.length}. Waiting 10 seconds before the next user...`);
    await delay(10000);
  }

  fs.writeFileSync('followers.json', JSON.stringify(followers));
};

main().catch(console.error);

When I run this script, I get the following error:

TypeError: Cannot read properties of null (reading 'maxID')

It seems like the getUserFollowers method is not working as expected. I've checked the documentation and my usage appears to be correct. Could you please help me understand what might be going wrong here?

I'm running the script from the root directory of the project, so there should be no issues with versioning or accessing the correct methods.

Thank you for your time and assistance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions