Twitter Steam Api Randomly Stopped Working

I am using node.js and twit to track tweets which include the hashtag #DisasterMgtUWI in real time. It was working at first, and I managed to get the first two that I made from a test account. On the 3rd tweet, I included an image in the tweet. However, from this point onwards, no tweets that I made were logged to the console, even after restarting my server. My code is shown below:

const Twit = require('twit')
require('dotenv/config')
const T = new Twit({
    consumer_key: process.env.TWITTER_API_KEY,
    consumer_secret: process.env.TWITTER_API_SECRET,
    access_token: process.env.TWITTER_ACCESS_TOKEN,
    access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET
})

const stream = T.stream('statuses/filter', {track: '#DisasterMgtUWI'})

stream.on('tweet', tweet => {
    console.log(tweet)

})

Does anyone know why my code randomly stopped working? I'm at a loss.

1 Answer

I fixed the problem by hard-coding the API key values rather than using the variables from a .env file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Chloe Bennett

Chloe Bennett

Culture, Media & Entertainment Columnist

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.

Share this article
Twitter Facebook Pinterest