Pass array in beforeRender to server
-
Hi,
I am passing an array of length 2092 at beforeRender() but it loses data and becomes an object of 990 keys. In my server, where I receive the get request searchParams.prjIds as req.query, its no longer an array but an associate array and of length 990.
console.log("req query ids length", Array.isArray(req.query.prjIds), Object.keys(req.query.prjIds).length);
what do you see as bad practice or error in here.
Thanks in advance. I am really stuck here.function beforeRender(req, res, done) { // get search parameters let searchParams = { 'fields': req.data.fields || {}, 'prjIds': req.data.prjIds || [], // length of 2092 'displayHeaders': req.data.displayHeaders || {} }; request.get({ url: `${serverUrl}/cpms/rpt/portal`, qs: searchParams || {}, json: true }, (err, response, body) => { if (err) done(err); req.data.transactions = body || []; done(); }
-
hi! hmm not sure, if you have the expected array of 2092 inside the jsreport script then it means something is wrong either in the
request
library or in your custom server, what are you using for parsing url encoded values in your server? are you using body-parser? check body parser options maybe there is some kind of default limit about the size of items you can have in an array serialized in url encoded form. difficult to tell you what can be wrong without knowing how your custom server looks like.
-
body-parser.
app.use(bodyParser.json()); // for parsing application/json
app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded