[英]Hyperledger Fabric- HistoryQueryIterator using nodejs
我正在嘗試使用nodejs創建超級賬本鏈代碼,fabric-shim對我來說是新的。 我正在嘗試使用getHistoryForKey()
獲取資產的歷史記錄。
我嘗試使用while
通過HistoryQueryIterator
進行迭代, HistoryQueryIterator
成功。
@Transaction()
public async getAllHistory(ctx:Context,key:string):Promise<void>{
const history = await ctx.stub.getHistoryForKey(key);
while(history.next()){
history.next().then(value =>{
console.info("================>",value.toString());
})
.catch(err =>{
console.info("ERROR",err);
})
}
}
上面的代碼給出[object Object]
。
如果有人可以指出正確的方向,那將會有所幫助。
您可以在Hyperledger Fabric官方示例(chaincodes / marbles02)中找到有關如何使用getHistoryForKey
的示例。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.