Thanks, the key here for me was creating the script as an asset (config.js), not a Script.
F
flintavenue-mike
@flintavenue-mike
0
Reputation
2
Posts
208
Profile views
0
Followers
0
Following
Posts made by flintavenue-mike
-
RE: Inject a base url for my remote api that is called by a number of scripts in the jsreport online service
-
Inject a base url for my remote api that is called by a number of scripts in the jsreport online service
Hello,
I am able to set a root url via the dotenv package for my on premise reporting service, but I couldn't find in the documentation how do accomplish the same thing using the online reporting service.
Here's an example from my on premise server:
const process = require('process'); var getRequest = require('request'); function beforeRender(req, res, done) { var baseUrl = process.env.JSREPORT_BASE_URL; var url = baseUrl + 'balance_due_listing/'; console.log(url + req.data.campaignId); getRequest(url + req.data.campaignId, function(err, resp, body) { console.log(body); if (err) { return done(err); } req.data.rows = JSON.parse(body); console.log(req.data.rows); done(); })
I'm not set on a specific method of doing this, I would just like to be able to update the baseUrl depending on my environment.
Thanks!