Unsupported module in scripts: http.
-
I used the following code on jsreport to generate the html report,
var http = require('http'); function beforeRender(req, res, done) { require('request')({ url:"http://157.232.10.106:31210/api/project/v1/reports/gethookdata/bsr_test_med_instr/234/3879", json:true }, function(err, response, body){ req.data.posts = body; done(); }); }
Here i got the error "unsupported module in scripts: http. can some one help me
-
The error message actually tells you what you need to change in the config. Did you try it?
-
i can't get clearly, in which config i should change
-
The docs to read...
https://jsreport.net/learn/configuration
https://jsreport.net/learn/scripts
-
"scripts": {
"allowedModules" : ["http"]
}i added the the above code in my package.json file in my nodejs application. but same error was thrown, The jsreport i am running on my node js application.
-
Ah ok, you didn't mentioned that.
You can for example pass this config when creating jsreport instance
require('jsreport')({ "scripts": { "allowedModules" : ["http"] } })
Other methods are described in https://jsreport.net/learn/configuration
-
I used above code in my server.js on my node js application, the jsreport was produce same error.
The jsreport studio i ran through my node js application by following command
"require('jsreport')({ httpPort: 3000, httpsPort: 0 }).init(); "
Here jsreport run on 3000 port and my applicaiton run on 9000 port
-
You should extend
{ httpPort: 3000, httpsPort: 0 }
with thescripts
config.
-
Thank u very much jan balha
-
hi i got error while generate report
"Handlebars is not defined" i used following code in helper.js sectionHandlebars.registerHelper('ifCond', function(v1, v2, options) {
if(v1 == '(Stop)') {
return options.fn(v2);
}
return options.inverse(v1);
});Handlebars.registerHelper('ifCond2', function(v1, v2, options) {
if(v1 == '(Continued)' || v1== '(Changed)') {
return options.fn(v2);
}
return options.inverse(v1);
});Handlebars.registerHelper('ifCond3', function(v1, v2, options) {
if(v1 == '(New)') {
return options.fn(v2);
}
return options.inverse(v1);
});
-
This is not how you define helpers in jsreport. There is general way which works across all engines. See the get started docs
https://jsreport.net/learn/get-started
-
Please read our docs before answering further questions. All of this is not something you wouldn't figure out on your own if you would be a little bit patient.
Thank you.