[英]Hyperledger Fabric- HistoryQueryIterator using nodejs
I am trying to create hyperledger chaincode using nodejs and fabric-shim is new to me. 我正在尝试使用nodejs创建超级账本链代码,fabric-shim对我来说是新的。 I am trying to fetch history of an asset using
getHistoryForKey()
. 我正在尝试使用
getHistoryForKey()
获取资产的历史记录。
I tried iterating through HistoryQueryIterator
using while
but i was not successful. 我尝试使用
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);
})
}
}
The above code gives [object Object]
. 上面的代码给出
[object Object]
。
If someone could point me in the right direction it would be helpful. 如果有人可以指出正确的方向,那将会有所帮助。
You can find an example about how to use getHistoryForKey
in the official Hyperledger Fabric samples ( chaincodes/marbles02). 您可以在Hyperledger Fabric官方示例(chaincodes / marbles02)中找到有关如何使用
getHistoryForKey
的示例。
https://github.com/hyperledger/fabric-samples/blob/release-1.4/chaincode/marbles02/node/marbles_chaincode.js https://github.com/hyperledger/fabric-samples/blob/release-1.4/chaincode/marbles02/node/marbles_chaincode.js
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.