Hello,
My meteor app is connected with a microservice. (Authentification with token).
At some point, my user click on a button, it triggers a method, which do a HTTP.call :
// Event on client :
'click .js-my-export': function (event, templateInstance) {
event.preventDefault();
...
Meteor.call('exportMyPDF', options, (err, res) => {
if (err) console.log(err);
const blob = new Blob(
[res.content],
{ type: `${res.headers['content-type']};base64` }
// { type: 'application/octet-stream;' }
);
const fileURL = URL.createObjectURL(blob);
window.open(fileURL);
// saveAs(blob, 'mydoc.pdf');
});
},
// On server :
export function exportMyPDF(...) {
const options = ...;
return HTTP.call('GET', `microservice_url/api/exports/mypdf`, options);
}
However it didn’t works, when I go directly to the microservice route with my navigator or postman I got the response without problems. ( A pdf with some content ). So I have the feeling that I am not doing the redirection nicely with meteor, something, somewhere is corrupted, is return HTTP.call a good solution ?
If it can helps here is the response from the server ( console.log(res) ) : { res : Object } printed in the console:
content: "%PDF-1.4↵1 0 obj↵<<↵/Title (��)↵/Creator (��)↵/Prod ..... lots of characters....%"
data: null,
statusCode: 200,
headers: {
connection: "close",
content-disposition: "attachment; filename=myDoc.pdf"
content-type: "application/pdf",
date: "date",
transfer-encoding: "chunked",
x-powered-by: "Express"
}