如何将多个脚本文件添加到Hyperledger Composer Playground

时间:2019-06-14 13:02:34

标签: hyperledger-composer

我有一个分布在2个脚本文件中的代码。一个是Hyperledger Composer Playground提供的 logic.js 。还有另一个脚本文件- optedServices.js ,其中定义了一个函数getService()。我需要在logic.js的代码中调用此函数getService()。请让我知道该怎么做。在此先感谢-Madhu

我尝试了左下角的“ Add a file”链接。拖放optedServices.js并按下“添加”按钮。其中包括了Playground用户界面中的文件。

文件logic.js包含:

function numToString(optedService) {

if (optedService == "") {
    return ""
}

var optedService2 = require('./optedService');

optedServices = optedService2.getService('2' + optedService);
 .......

return optedServices;
}

文件optedService.js包含:

function getService (number) 
{

.
.
.

  return 'Sting1 & String2';

}


module.exports = {

        getService:getService

}

预期结果:“ Sting1&String2”

实际结果:

Error: Error trying invoke business network with transaction id 22b513d8dbbf765bd23e3f448c45d2464e19b6c35628e23989c0a25f6a018b49. Error: No valid responses from any peers. Response from attempted peer comms was an error: Error: 2 UNKNOWN: error executing chaincode: transaction returned with failure: ReferenceError: module is not defined

0 个答案:

没有答案
相关问题