How to extend Composer rest Server ?

0 votes

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 ?

Sep 20, 2018 in Blockchain by sabby
• 4,050 points
46 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

 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.

answered Sep 20, 2018 by Perry
• 16,450 points

Related Questions In Blockchain

+1 vote
1 answer

I am unable to change port of composer-rest-server. Please help!

Use full format for running a business ...READ MORE

answered Mar 27, 2018 in Blockchain by Christine
• 15,790 points
206 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to use different network cards for multiple composer rest server users?

You are getting the same network card in ...READ MORE

answered Dec 5, 2018 in Blockchain by Perry
• 16,450 points
228 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.