Hi, this regularly confuses me and I have just spent the last 45 minutes now trying to get something to work.
I have a bot that uses the Twitter API and I want to pull the accounts being followed by a given account and add those to an array to be worked on in another module, so what I have so far is:
getUsersList.js:
const Twit = require('twit')
const config = require('./config')
const bot = new Twit(config)
let users = []
const listOutFollowers = userName => {
bot.get(
'friends/ids',
{
screen_name: userName,
count: 200
},
function getData(err, data, response) {
if (err) {
console.log(err)
return
}
users.push(data.ids)
if (data['next_cursor'] > 0) {
bot.get(
'followers/ids',
{
screen_name: userName,
count: 200,
next_cursor: data['next_cursor']
},
getData
)
}
}
)
}
module.exports = { users }
Then I want to be able to call it from another module:
bot.js:
const users = require('getUsersList.js')
// do something with array
I’m not able to get anything back from the other module