Rishikant181 / Rettiwt-API

A CLI tool and an API for fetching data from Twitter for free!
https://rishikant181.github.io/Rettiwt-API/
MIT License
309 stars 31 forks source link

Cannot set properties of undefined (setting 'tweet') #352

Closed TheUltimateAbsol closed 11 months ago

TheUltimateAbsol commented 11 months ago

Ok, this is probably just my stupidity, but I can't seem to initialize the module for the love of me.

All I have done is just done these lines

import { Rettiwt } from "rettiwt-api";
const API_KEY='some-cookie-value'
const rettiwt = Rettiwt(API_KEY);

whereas some-cookie-value is the value of the cookie line from the cli command login <email> <username> <password> using the Rettiwt-Auth package globally. (The CRSF token and the Bearer token were discarded... did I need these for something...?)

TypeError: Cannot set properties of undefined (setting 'tweet')
    at Rettiwt (/mnt/c/Users/thebe/Documents/like-counter/node_modules/rettiwt-api/dist/Rettiwt.js:24:20)
    at file:///mnt/c/Users/thebe/Documents/like-counter/getTweets.js:6:17
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:526:24)
    at async loadESM (node:internal/process/esm_loader:91:5)
    at async handleMainPromise (node:internal/modules/run_main:65:12)

What am I doing wrong here? This is where I get called out for not being a javascript dev I guess...

Rishikant181 commented 11 months ago

@TheUltimateAbsol What is the data that you are trying to fetch?

TheUltimateAbsol commented 11 months ago

basic user info and tweets from a user

rettiwt.user.details('username')
.then(details => {
    console.log(details)
})
.catch(error => {
    console.error("error fetching details")
})

rettiwt.tweet.search({
    fromUsers: ['username'],
})
.then(data => {
    console.log(data)
})
.catch(err => {
    console.error("help I failed")
})
TheUltimateAbsol commented 11 months ago

But the aforementioned error occurs before I get to that code. I am using NodeJS 18.14.2

Rishikant181 commented 11 months ago

@TheUltimateAbsol I need the username whose tweets you are trying to fetch to reproduce the error

TheUltimateAbsol commented 11 months ago

@Rishikant181 alkalinedd

Rishikant181 commented 11 months ago

const rettiwt = Rettiwt(API_KEY);

Oops, this a minor mistake in my documentation.

This is the proper way to initialize a new Rettiwt instance: const rettiwt = new Rettiwt(API_KEY);