From 6fd327a347b8b0175ad83817ad4305eef5dfed29 Mon Sep 17 00:00:00 2001 From: nikhil550 Date: Wed, 13 Jan 2021 15:37:34 -0500 Subject: [PATCH] Fix error that occurs with go CC and javascript app (#399) Signed-off-by: Nikhil Gupta --- asset-transfer-basic/application-javascript/app.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/asset-transfer-basic/application-javascript/app.js b/asset-transfer-basic/application-javascript/app.js index 7f368c61..fc8eeca5 100644 --- a/asset-transfer-basic/application-javascript/app.js +++ b/asset-transfer-basic/application-javascript/app.js @@ -129,15 +129,10 @@ async function main() { // to the orderer to be committed by each of the peer's to the channel ledger. console.log('\n--> Submit Transaction: CreateAsset, creates new asset with ID, color, owner, size, and appraisedValue arguments'); result = await contract.submitTransaction('CreateAsset', 'asset13', 'yellow', '5', 'Tom', '1300'); - // The "submitTransaction" returns the value generated by the chaincode. Notice how we normally do not - // look at this value as the chaincodes are not returning a value. So for demonstration purposes we - // have the javascript version of the chaincode return a value on the function 'CreateAsset'. - // This value will be the same as the 'ReadAsset' results for the newly created asset. - // The other chaincode versions could be updated to also return a value. - // Having the chaincode return a value after after doing a create or update could avoid the application - // from making an "evaluateTransaction" call to get information on the asset added by the chaincode - // during the create or update. - console.log(`*** Result committed: ${prettyJSONString(result.toString())}`); + console.log('*** Result: committed'); + if (`${result}` !== '') { + console.log(`*** Result: ${prettyJSONString(result.toString())}`); + } console.log('\n--> Evaluate Transaction: ReadAsset, function returns an asset with a given assetID'); result = await contract.evaluateTransaction('ReadAsset', 'asset13');