Search code examples
hyperledger-fabrichyperledger-fabric-ca

How can i get username fron fabric-client , where name set in registerUser.js?


My objective is to show username in web page, where I create user using the following code.

 return fabric_client.createUser(
     {username: 'user1',
     mspid: 'Org1MSP',
     cryptoContent: { privateKeyPEM: enrollment.key.toBytes(), signedCertPEM: enrollment.certificate }
     });

I couldn't find the way to get the username.


Solution

  • I assume you're calling the Client.createUser function. It returns (asynchronously) a User object which has a getName() function. Looking at the docs and source, it would appear that the user name field is used to store the username.

    Take special note that the function is async, meaning that it returns a promise that will resolve to a User.