1
Braintree提供了搜索事务的api。 Braintree提供了一个例子,但我不知道如何阅读braintree返回的节点流。请看下面的代码片段:如何使用braintree返回的节点流
var stream = gateway.transaction.search(function (search) {
search.paymentMethodToken().is("h337xg");
});
stream.pipe(someWritableStream);
//When I try to print the stream in console, I get the following result:
{
_readableState:
{ highWaterMark: 16384,
buffer: [],
length: 0,
pipes: null,
pipesCount: 0,
flowing: false,
ended: false,
endEmitted: false,
reading: false,
calledRead: false,
sync: true,
needReadable: false,
emittedReadable: false,
readableListening: false,
objectMode: true,
defaultEncoding: 'utf8',
ranOut: false,
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null },
readable: true,
domain: null,
_events: {},
_maxListeners: 10,
searchResponse: { stream: [Circular], success: true },
currentItem: 0,
currentOffset: 0,
bufferedResults: []
}
好吧。我曾尝试解析对象,但无法这样做。 someWritableStream.on(“end”,function(){ // Do接收到所有块后的某些事情 console.log(completeData); JSON.parse(completeData); }); – Prem 2015-03-02 16:29:33