我試圖返回tweet給予預定義的搜索條件,變量只是作爲示例的佔位符。問題在於,代碼運行時,變量tweets和配置文件返回'undefined'。我不確定這是爲什麼而不是'對象對象',任何幫助將不勝感激。函數returing undefined tweets
var count = 10,
profile = 'manutd',
date = '2011-11-11',
keyword = 'man city',
lan = 'en',
search = keyword + " since:" + date + " lang:" + lan;
var tweets = getTweets();
var profiles = getProfile();
console.log('Started')
function handleTweets(err, data){
if (err) {
console.error('Get error', err)
}
else {
console.log('Get Tweets');
console.log(tweets);
console.log('Finished');
}
}
function handleFriends(err, data){
if (err) {
console.error('Get error', err)
}
else {
console.log('Get Friends');
console.log(profiles);
console.log('Finished');
}
}
function getTweets(){
client.get('search/tweets', { q: search, count: count, from: profile },
handleTweets)
}
function getProfile(callback){
client.get('friends/list', { screen_name: profile, count: count },
handleFriends)
}
你錯過了'函數'getTweets return'() '&'getProfile()'; – itzmukeshy7
啊我的不好,謝謝 – user4357505