I am using composer embeded to test my code, when

2019-08-25 10:38发布

I was writing composer test.In my origin codes, the logic.js include request.post which interact with other server. I add var request = require('request') in the beginning to avoid error which is "error 'request' is not defined". in this way, I can translate the package into a .bna file, and work well. But when I try to write some unit test with 'embeded', the error came up with ReferenceError: require is not defined. I add the 'require' package in my package.json file.

1条回答
Summer. ? 凉城
2楼-- · 2019-08-25 11:11

this is because that 'eslint' is complaining it doesn't know what to do with request when you run npm test etc. We shoud add the comment like

/* global getAssetRegistry getFactory emit request */

follow the example: https://github.com/hyperledger/composer-sample-networks/blob/master/packages/basic-sample-network/lib/sample.js#L15

查看更多
登录 后发表回答