I have a code distributed in 2 Script files. One is the logic.js provided by Hyperledger Composer Playground. And another script file - optedServices.js in which I have a function getService() defined. I need to call this function getService() in the code of logic.js. Please let me know how to do this. Thanks in advance - Madhu
I tried 'Add a file' link in the bottom left corner. And drag and dropped the optedServices.js and pressed 'add' button. That included the file in UI of playground.
The file logic.js contains:
function numToString(optedService) {
if (optedService == "") {
return ""
}
var optedService2 = require('./optedService');
optedServices = optedService2.getService('2' + optedService);
.......
return optedServices;
}
The file optedService.js contains:
function getService (number)
{
.
.
.
return 'Sting1 & String2';
}
module.exports = {
getService:getService
}
Expected result: 'Sting1 & String2'
Actual Result:
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
Related
I need to create a file and copy it somewhere by some code from cypress .
the first step is done by using cy.writeFile and now myfile.txt is created
Now i need to copy it somewhere like c:/lib/Sth
i used this command cy.exec('cp myfile.txt c:/lib/sth')
it shows this error message :
CypressError: cy.exec('cp myfile.txt c:/lib/sth') failed because the command exited with a non-zero code. Pass {failOnNonZeroExit: false}` to ignore exit code failures.
Information about the failure:
Code: 127
I add {failOnNonZeroExit: false} to my code to ignore error , it works , but my file is not copied.
is there any other solution to copy my file from cypress ??
A work-around you could do is set up a custom cypress task to execute a command.
Something like
// cypress/plugins/index.ts
const { exec } = require('child_process');
/**
* #type {Cypress.PluginConfig}
*/
// eslint-disable-next-line no-unused-vars
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
on('task', {
async execute(command: string) {
return new Promise((resolve, reject) => {
try {
resolve(exec(command));
} catch (e) {
reject(e);
}
});
},
});
};
Then execute like so
cy.task('execute', 'cp myfile.txt c:/lib/sth');
This was a potential solution I came up with when cy.exec() didn't work for me either when trying to execute a relatively complex node script.
Another thing you could try is to create a really simple script that copies the file, and try executing that script.
Best of luck!
I'm trying to get sender accountId in contract and getting error.
My contract:
#nearBindgen
export class Contract {
private message: string = 'Hello '
helloWorld(): string {
const predecessor = Context.predecessor
return this.message + predecessor
}
}
I'm trying to access contract from CLI with following command(with my account id):
near view $CONTRACT helloWorld --accountId <id>.testnet
Error:
Error: Querying [object Object] failed: wasm execution failed with error: FunctionCallError(HostError(ProhibitedInView { method_name: "predecessor_account_id" })).
Oops. I should use
near call
instead of
near view
I am getting the error below when i try to upload a file greater than 25mb to amazon s3 using laravel aws sdk, however files below 25mb are uploading successfully. I have everything setup correctly in my .env file. I have no idea why this is happening.
Any help would be appreciated.
Error:
Error executing "ListObjects" on
"bucketdomain/?prefix=b6d767d2f8ed5d21a44b0e5886680cb9%filename%2F&max-keys=1&encoding-type=url";
AWS HTTP error: cURL error 7: Failed to connect to bucketdomain
port 443: Network unreachable (see
http://curl.haxx.se/libcurl/c/libcurl-errors.html)
Save function in laravel:
$v = Storage::disk('s3')->put($path, file_get_contents($file), 'public');
unlink($file->getPathname());
return response()->json(["message" => "File uploaded successfully!"]);
Upload function in laravel:
if ($receiver->isUploaded() === false) {
throw new UploadMissingFileException();
}
$save = $receiver->receive();
if ($save->isFinished()) {
database entries...
return $this->saveChunkFile($file,$userFolderName,$path,$fileName);
}
$handler = $save->handler();
return response()->json([
"Percentage" => $handler->getPercentageDone()
]);
I am using reusable.js in client side to upload files in chunks & the code above is to handle the chunks and merge them when done and pass to the saveChunkFile function.
Picture:
The file is to be stored in the 2nd folder from top but there is not file that is why i think the error is thrown on size function and these files (chunks) are being generated and not stopping still.
I'm using jsreport to render HTML and generate a PDF file and it works locally, but on Lambda, it throws this error:
{
"errorMessage": "Error during rendering report: Cannot read property 'filter' of undefined",
"errorType": "TypeError",
"stackTrace": [
"Phantom.execute (/var/task/node_modules/jsreport-phantom-pdf/lib/phantom.js:169:53)",
"/var/task/node_modules/jsreport-core/lib/render/render.js:118:23",
"tryCatcher (/var/task/node_modules/bluebird/js/release/util.js:16:23)",
"Promise._settlePromiseFromHandler (/var/task/node_modules/bluebird/js/release/promise.js:512:31)",
"Promise._settlePromise (/var/task/node_modules/bluebird/js/release/promise.js:569:18)",
"Promise._settlePromise0 (/var/task/node_modules/bluebird/js/release/promise.js:614:10)",
"Promise._settlePromises (/var/task/node_modules/bluebird/js/release/promise.js:693:18)",
"Async._drainQueue (/var/task/node_modules/bluebird/js/release/async.js:133:16)",
"Async._drainQueues (/var/task/node_modules/bluebird/js/release/async.js:143:10)",
"Immediate.Async.drainQueues (/var/task/node_modules/bluebird/js/release/async.js:17:14)",
"runCallback (timers.js:672:20)",
"tryOnImmediate (timers.js:645:5)",
"processImmediate [as _immediateCallback] (timers.js:617:5)"
]
}
Same environment variables, same Node version.
Here's the line that generates the error above: https://github.com/jsreport/jsreport-phantom-pdf/blob/ad8d42e640348abffe77f2fed818528bee3eed98/lib/phantom.js#L169
var phantom = this.definition.options.phantoms.filter(function (p) {
return p.version === request.template.phantom.phantomjsVersion
})
which implies the object path options.phantoms is undefined.
You'll have to check how definitions is set up in your Lambda.
As it turned out, it was a problem of this library: node-app-root-path.
I fixed it by passing the correct rootDirectory option to jsreport.
After installation wizard is finished I get this error.
Slim Application Error
The application could not run because of the following error:
Details
Type: RuntimeException
Message: Identifier DB not initialized yet
File: /.../recovery/install/src/ContainerProvider.php
Line: 162
Is there is some configuration file where I can set DB params? I had insert all params via installation wizard.
In file recovery/install/src/ContainerProvider.php
Add 2 strings:
In use-section
use Shopware\Recovery\Update\Utils;
2.Inside the register-function:
$container['db'] = function ($c) {
$conn = Utils::getConnection(SW_PATH);
return $conn;
};