junhoyeo / threads-api

Unofficial, Reverse-Engineered Node.js/TypeScript client for Meta's Threads. Web UI Included.
https://threads.junho.io
MIT License
1.58k stars 134 forks source link

Issue with getThreadLikers(postID) method in threads-api #175

Closed a-burlakovv closed 11 months ago

a-burlakovv commented 11 months ago

Dear Developer,

I am currently using your threads-api package in my Node.js project and I am encountering an issue with the getThreadLikers(postID) method.

Here is the code snippet that I am using:

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

const main = async () => { const threadsAPI = new ThreadsAPI({ username: 'username', password: 'password', });

const postURLs = [ 'https://www.threads.net/t/Cuugaf_M_SV', 'https://www.threads.net/t/CuugTF3MqZW', // More URLs... ];

let likers = [];

for (const url of postURLs) { const postID = threadsAPI.getPostIDfromURL(url); const likersForPost = await threadsAPI.getThreadLikers(postID); likers = likers.concat(likersForPost); }

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

main().catch(console.error);`

When I run this script, I am encountering the following error:

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

This error suggests that the getThreadLikers(postID) method is returning null or undefined. I have checked the post URLs and they are valid.

Could you please provide some guidance on why this might be happening and how I could resolve this issue? Any help would be greatly appreciated.

Aerglonus commented 11 months ago

@a-burlakovv should be fixed now with latest release v1.5.3

nawafab commented 11 months ago

Hello @Aerglonus ,

The issue was not fixed on the new release for both methods 👍 const post = await threadsAPI.getThreads(postID); const post = await threadsAPI.getThreads(postID); log for likers:

- error TypeError: Cannot read properties of null (reading 'likers')
    at o.eval (webpack-internal:///(sc_server)/./node_modules/threads-api/build/threads-api.js:935:47)
    at eval (webpack-internal:///(sc_server)/./node_modules/threads-api/build/threads-api.js:144:27)
    at Object.eval [as next] (webpack-internal:///(sc_server)/./node_modules/threads-api/build/threads-api.js:158:14)
    at i (webpack-internal:///(sc_server)/./node_modules/threads-api/build/threads-api.js:25:21)
    at o (webpack-internal:///(sc_server)/./node_modules/threads-api/build/threads-api.js:38:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

log for post :

- error TypeError: Cannot read properties of null (reading 'data')
    at o.eval (webpack-internal:///(sc_server)/./node_modules/threads-api/build/threads-api.js:912:47)
    at eval (webpack-internal:///(sc_server)/./node_modules/threads-api/build/threads-api.js:144:27)
    at Object.eval [as next] (webpack-internal:///(sc_server)/./node_modules/threads-api/build/threads-api.js:158:14)
    at i (webpack-internal:///(sc_server)/./node_modules/threads-api/build/threads-api.js:25:21)
    at o (webpack-internal:///(sc_server)/./node_modules/threads-api/build/threads-api.js:38:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Aerglonus commented 11 months ago

Hello @Aerglonus ,

The issue was not fixed on the new release for both methods +1 const post = await threadsAPI.getThreads(postID); const post = await threadsAPI.getThreads(postID); log for likers:

make sure you updated npm update threads-api | pnpm update threads-api to the newest release

nawafab commented 11 months ago

It seems the issue is related to the data that I am using for the test that causes the error above , on other posts it works fine

    const postID = threadsAPI.getPostIDfromThreadID('NTc4MTIwNjQ2YQ');

    if (!postID) {
        return;
    }
    const post = await threadsAPI.getThreads(postID);
    console.log(JSON.stringify(post.containing_thread));
    console.log(JSON.stringify(post.reply_threads));

    const likers = await threadsAPI.getThreadLikers(postID);
    console.log(JSON.stringify(likers));
ishaanbuildsthings commented 10 months ago

Did anyone figure out why this doesn't work? I am still having these issues. I tried alternate posts as well and I am still having issues.

Hello @Aerglonus ,

The issue was not fixed on the new release for both methods 👍 const post = await threadsAPI.getThreads(postID); const post = await threadsAPI.getThreads(postID); log for likers:

- error TypeError: Cannot read properties of null (reading 'likers')
    at o.eval (webpack-internal:///(sc_server)/./node_modules/threads-api/build/threads-api.js:935:47)
    at eval (webpack-internal:///(sc_server)/./node_modules/threads-api/build/threads-api.js:144:27)
    at Object.eval [as next] (webpack-internal:///(sc_server)/./node_modules/threads-api/build/threads-api.js:158:14)
    at i (webpack-internal:///(sc_server)/./node_modules/threads-api/build/threads-api.js:25:21)
    at o (webpack-internal:///(sc_server)/./node_modules/threads-api/build/threads-api.js:38:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

log for post :

- error TypeError: Cannot read properties of null (reading 'data')
    at o.eval (webpack-internal:///(sc_server)/./node_modules/threads-api/build/threads-api.js:912:47)
    at eval (webpack-internal:///(sc_server)/./node_modules/threads-api/build/threads-api.js:144:27)
    at Object.eval [as next] (webpack-internal:///(sc_server)/./node_modules/threads-api/build/threads-api.js:158:14)
    at i (webpack-internal:///(sc_server)/./node_modules/threads-api/build/threads-api.js:25:21)
    at o (webpack-internal:///(sc_server)/./node_modules/threads-api/build/threads-api.js:38:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)