0
解析從Facebook一個GET響應如何可以解析從這裏使用Facebook的node.js的一個GET響應是我的代碼:我如何使用Node.js的
var options = {
host: 'graph.facebook.com',
path: 'url',
key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'),
agent: false
};
var fb = https.get(options, function(res) {
console.log("statusCode: ", res);
res.on('data', function(d) {
console.log(d);
});
}).on('error', function(e) {
console.error(e);
});
而不是打印我期望的數據,它正在打印一些緩衝值。
其打印響應。如果您需要字符串而不是緩衝區,請使用console.log(d.toString())。如果您需要完整的響應主體,請將其與先前的值連接起來。 –