1
以下是搜索事务的braintree api。结果以流的形式收到。但无法读取所接收的字符串或所需格式的块。如何使用node.js读取分块流
var stream = gateway.transaction.search(function (search) {
result = search.paymentMethodToken().is("h337xg");
});
completeData = ""
stream.on("data", function(chunk){
// read the chunk
completeData += chunk;
});
stream.on("end", function(){
// print the output in console
console.log(completeData);
});
stream.resume();
,可以在控制台中看到的输出是: [对象的对象] [对象的对象] [对象的对象] [对象的对象] [对象的对象] [对象的对象] [对象的对象]
您是否尝试过console.log(JSON.stringify(chunk))?它可能是JSON而不是字符串 – nkskalyan 2015-03-03 09:10:03