privatenumber / snap-tweet

Snap a screenshot of a tweet 📸
MIT License
333 stars 19 forks source link

How to import snap-tweet in my nodejs app #40

Open FelixDubois opened 1 year ago

FelixDubois commented 1 year ago

Hey 👋, I want to use snap-tweet in my Node.js app.

I have installed the package using this command: npm i -g snap-tweet.

And my code looks like this:

const TweetCamera = require('snap-tweet')

TweetCamera.snapTweet('1420000000000000000');

But I am getting this error: TypeError: TweetCamera.snapTweet is not a function.

So I debugged the TweetCamera object and found that it returned { default: [Getter] }. When I log TweetCamera.default, I get [class yn].

When I write const tweetCamera = new TweetCamera(), I get this error: TypeError: TweetCamera is not a constructor.

So I don't really know what is happening right here. Even after reading the source code, I can't find where I'm messing up. I'm new to Node.js app development, so your help would be awesome.

FelixDubois commented 1 year ago

Well, I successfully did it. I passed my project as a module, took the code that I was interested in, and translated it into JS. Probably it's the worst way possible but I don't know how to do it and it's working.