0

I made a Hyperledger composer Network. I want to see My function that have a query code.

for example, My function' content is

/**
 * @param {hansung.ac.kr.transaction.selectUserByCertificateName}  tx  - the member to be processed
 * @transaction
 */
function selectUserByCertificateName (tx) {
  var idList = [];

  query("selectCertificateByName" , {targetName: tx.certificateName })
  .then(function (certificateList) {
     certificateList.forEach(function (certificate) {
     idList.push(certificate.ownerId);
     })
  }).then(function () {
     idList.forEach(function (id) {
        query("selectUserById" , {targetId: id })
        .then(function (userList){
         console.log(userList); 
        });
     })
  });

}

this case, I attempt to console.log. I want to see this result(userList) in my angular page.

In angular, http.get method is used for receiveing rest-server data
but, I don't know how to editing composer-rest-server response format I want to sending userList to rest Response.

How to extend Composer rest Server ?

if another way To get Data is exist, please give advice

a bc
  • 43
  • 1
  • 1
  • 7

1 Answers1

0

I think it's the wrong approach you're doing. It looks like you want to query something from the custom composer-rest-server having access to your deployed Business Network.

As you want to build a REST query endpoint at the end, you have to implement a simple Hyperledger Composer Query definition. composer-rest-server offers all your query definitions as a GET request.

To learn and understand I can highly recommend you this Composer & REST server query tutorial. Another thing I'd like to recommend you is not to work with console.log at all in transaction processor functions. The logged results can only be seen when executed in a browser connection in Composer Playground or when the code is executed through unit/Cucumber tests.

jpietzsch
  • 536
  • 5
  • 18
  • Thank you, But I want to query in My example transaction. – a bc May 02 '18 at 00:32
  • I want to query about different two table. so I will use my example transaction(query in transaction) I know query in queries.qry that offers GET request. But I need to query transaction function in model file . – a bc May 02 '18 at 00:37