首先,我很感谢你的帮助。
当我试图获得特定地区的热门趋势时。对于以下代码:-
var Twit = require('twit');
var config = require('./config');
var T = new Twit(config);
var params = {
id: '1'
// count: 3
}
T.get('trends/place', params, gotData);
function gotData(err, data, response) {
var tweets = data;
console.log(tweets);
}我期待的是像this (click and go to Example Response)这样的数据
但是我得到的回复是这样的
C:\Users\Yash\IdeaProjects\yash>node bot3.js
[ { trends:
[ [Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object] ],
as_of: '2018-01-25T14:59:11Z',
created_at: '2018-01-25T14:54:58Z',
locations: [ [Object] ] } ]如果有人能帮我解决这个问题,我将不胜感激。我对node.js非常陌生。这是为了一个大学项目,但我被困住了。
发布于 2018-01-26 00:36:11
您希望将返回的JSON对象转换为字符串以供显示,因此可以使用(例如) console.log(JSON.stringify(tweets, undefined, 2));。stringify的第二个和第三个参数会使输出以更易读的方式格式化。
https://stackoverflow.com/questions/48445992
复制相似问题