junhoyeo / threads-api

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

Can't publish anything: UnhandledPromiseRejectionWarning: TypeError: i.sent(...).data.split(...)[1].split(...)[0].replaceAll is not a function #87

Closed getrasa closed 1 year ago

getrasa commented 1 year ago

Here's the code:

const main = async () => {
    const accountUsername = "my_username";
    const accountPassword = "my_password";
    const threadsApi = new ThreadsAPI({username: accountUsername, password: accountPassword})

    const success = await threadsApi.publish("Publishing test!");
      console.log(`Status: ${success ? 'Success' : 'Failure'}`);
}
main();

As you can see vary basic example.

And here's an error:

 UnhandledPromiseRejectionWarning: TypeError: i.sent(...).data.split(...)[1].split(...)[0].replaceAll is not a function
    at d.<anonymous> (/home/getrasa/work/threads/threads-auto-ts/node_modules/threads-api/build/threads-api.js:1:9832)
    at /home/getrasa/work/threads/threads-auto-ts/node_modules/threads-api/build/threads-api.js:1:1769
    at Object.next (/home/getrasa/work/threads/threads-auto-ts/node_modules/threads-api/build/threads-api.js:1:1874)
    at o (/home/getrasa/work/threads/threads-auto-ts/node_modules/threads-api/build/threads-api.js:1:350)
    at i (/home/getrasa/work/threads/threads-auto-ts/node_modules/threads-api/build/threads-api.js:1:547)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:28058) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:28058) [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.
Mineru98 commented 1 year ago

In general, I've seen this error happen more often with private accounts or when Instagram has secondary security.

  1. If it's a private account, you need to convert it to a public account.
  2. you need to change the security level of your Instagram to be accessible with just a password.
  3. You should try logging in from a different browser session and see if there are any issues.
itsnikhil commented 1 year ago

I am also facing same issue. My account is public. @Mineru98 can you please share more details regarding point 2

itsnikhil commented 1 year ago

ok it working after updating to node 16 https://stackoverflow.com/a/76461878

itsnikhil commented 1 year ago

you can close this issue

getrasa commented 1 year ago

Legend! Problem solved.