无法通过Twitter API获得承诺价值

我正在试验NodeJS和twitter API。 我需要一个承诺的帮助。 函数requestFollowers应该返回一个承诺,它会。 当我在节点cli中运行文件时,它表示处理,并且从不logging该值。 如何获得我期望的价值,或者如何解决?

这是我所拥有的。

 function requestFollowers(tweep) { return new Promise(function(resolve, reject) { twitter.get('followers/list', { count: 200, skip_status: true, screen_name: tweep }, function(error, followers) { if (error) { console.log('followers list/ error >', error); reject(error); } else { resolve(followers.users.map(thing => thing.screen_name)); } }); }); } function onMention(error, tweets) { if (error) { console.log('mentions_timeline/ error >', error); } else { //console.log('mentions_timeline/ tweets >', tweets); let mentioned = tweets[0].entities.user_mentions .filter(thing => thing.screen_name !== user.screen_name) .map(thing => thing.screen_name); var list1 = requestFollowers(mentioned[0]), list2 = requestFollowers(tweets[0].user.screen_name); console.log('list1 >', list1.then(val => val).catch(error => error)); console.log('list2 >', list2.then(val => val).catch(error => error)); } } var config = require('./config'), Twitter = require('twitter'), twitter = new Twitter(config), user = { screen_name: 'screen_name' }, /** @param {string} status */ getStatus = status => ({ status }); twitter.get('statuses/mentions_timeline', user, onMention); 

你可以改变这一行console.log('list1 >', list1.then(val => val).catch(error => error)); 类似的东西

 list1.then(console.log).catch(console.error); 

你有什么是通过一个未解决的承诺链log和日志不解决参数的承诺之前打印它们 – 同步。 另外,你的then(val => val)是多余的,即使这会工作 – 你不需要另一个函数,只是返回它的input。