Get Response Headers Data
-
Hi, I am using express server POST request to submit data to jsreport server and its working fine. I need the permanent-link and blob name and other data as well. If I send post request from the postman, The headers are being printed as permanent-link and all. But In express route, How do i save these data and send the response. Please Help
-
Sorry but I don't get this. Please share some code parts and elaborate more.
-
var data = { template: {"name": templateName}, data:{ "aadhaar-number": aadhaarNumber, "verification-date": now, "verification-done-by": verificationDoneBy, "comments": comments, "client-name": clientName, "client-address": clientAddress, "client-branch": clientBranch, "src": `data:image/png;base64, ${base64data}`, "date": now }, options: { reports: { "save": true } } } var options = { uri: 'http://localhost:8001/api/report', method: "POST", json: data, } request(options).pipe(res);
So here, Now I can get the response as a file saving in the disk. But I need to send response as a json, which includes the permanent-link, blob-name, report-id.
-
You seem to use
request
npm module to invoke the request.
So you should check it's documentation to see how to get the response headers.
https://github.com/request/request#streamingrequest .get('http://google.com/img.png') .on('response', function(response) { console.log(response.statusCode) // 200 console.log(response.headers['permanent-link']) }) .pipe(request.put('http://mysite.com/img.png'))
Alternatively, because the
request
package is deprecated, you can check theaxios
module for making the HTTP calls.
https://github.com/axios/axiosOr check our official nodejs client
https://jsreport.net/learn/nodejs-client
-
Thank you for the reply. I am able to get the headers now. I have configured the JS report as in doccumentation and created some templates. Now my concern was, will my templates and data be safe? I mean, are my data and templates accessible by JSreport? or only I will have my data and templates with myself locally? Please answer.
-
You have your data where you configure it to be.
jsreport doesn't send data outside with the only exception: previewing office files. You can see this described in the documentation
https://jsreport.net/learn/office-preview
-
This post is deleted!
-
I want the complete downloadable url of the generated report with the extension, so that I can send it through API to the Client. As of now, I'm getting permanent-link as a url. But Client is not able to download this file from their end without extension and Proper file Name. Can you help.................
-
FYI, Our team has bought JS REPORT license for lifetime. Please Help. Thanks
-
But Client is not able to download this file from their end without extension and Proper file Name. Can you help............
what do you mean by that? The HTTP get on this URL will reach the stream of the report.
I see we don't set theContent-Disposition
header. That is the problem?
-
Thanks for replying. Anyway the problem is solved. I am using nodejs get router to make user download their reports using res.sendFile('Path of the report saved in jsreport directory').
Now we've come across new doubt. i.e We have docx file with table inside. When I write condition to check if the data exists in columns, if the data are not present I want whole row to be removed. But When I write if condition Text are being deleted but the empty row popups. What can be done? How to delete whole row or column when there is no data present in request body?