Hyperledger Fabric invokeChaincode returns Object object

0 votes

This is the queried function:

async query(stub, args) {
    let key = args[0]; //key
    let valueAsBytes = await stub.getState(key);
    let valString = valueAsBytes.toString('utf8');
    console.log('Value String: ', valString);
    return shim.success(valString);
}
The payload Buffer decodes to [Object object]
Nov 9, 2018 in Blockchain by slayer
• 29,370 points
1,033 views

2 answers to this question.

+1 vote
Best answer

Replace 

return shim.success(valString);

with:

return shim.success(Buffer.from(valString));

It should work now

answered Nov 9, 2018 by Omkar
• 69,220 points

selected Feb 7, 2019 by Priyaj
+1 vote
do Payload.toString() . it works for me
answered Feb 7, 2019 by Sanjeev

Related Questions In Blockchain

+4 votes
2 answers

How do I create a new block in Hyperledger Fabric?

This link might help you: https://github.com/hyperledger/fabric-sample ...READ MORE

answered Oct 11, 2018 in Blockchain by Sahu
2,654 views
+1 vote
2 answers

Challenge while setting up Hyperledger Fabric 1.0 in Ubuntu 16.04

The rocksdb error you're seeing wouldn't be ...READ MORE

answered Mar 27, 2018 in Blockchain by ned_crew
• 1,610 points

edited Jun 8, 2020 by Sirajul 1,153 views
+1 vote
1 answer
+1 vote
2 answers
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,451 views
0 votes
1 answer

Invalid Batch or signature in Savtooth

This will solve your problem import org.apache.commons.codec.binary.Hex; Transaction txn ...READ MORE

answered Aug 1, 2018 in Blockchain by digger
• 26,740 points
1,004 views
+1 vote
1 answer
+15 votes
5 answers
+16 votes
4 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP