I want to add an option to use a query to search for certain strings in a tweets stream. I want to switch the 'coding' string in the code for a query I get from the URL. How can I do that?
let nowTweets = (cb) => {
T.get('search/tweets', { q: 'coding', count: 10 }, function (err, data,response) {
const tweets = data.statuses
.map(tweet => tweet.text)
console.log(tweets);
cb(tweets)
})
}
app.get('/tweets', (req, res) => {
nowTweets(tweets => {
res.send('Tweets: ' + '\n' + tweets)
})
})
Use something like req.params
or req.query
to get your search string from the url of your route and pass it it as argument to your nowTweets()
For express: https://expressjs.com/en/api.html#req.params https://expressjs.com/en/api.html#req.query