So I am passing a data to my express route and the route will generate a pdf. This is my code:
Vue Method:
this.$http.post('http://localhost:3030/pdf', user_data).then(function(response) {
console.log('Success', response)
}, function(error) {
console.log('Error', error)
})
http://localhost:3030/pdf
res.render('pdf', {
personal_information: req.body.personal_information
}, function (err, html) {
//generate pdf
pdf.create(html).toBuffer(function (err, buffer) {
if (err) {
console.log(err)
next()
} else {
var pdfBuffer = new Buffer(buffer)
res.setHeader('Content-disposition', 'inline; filename="test.pdf"');
res.setHeader('Content-type', 'application/pdf');
res.send(pdfBuffer)
}
});
});
The code actually works, it is able to generate a pdf file that can be downloaded also but I am not getting a success response in my vue promise. This is what I get
Is there a way to handle this?
If your answer will include a cors issue, I just want you to know that I am using feathersjs and cors package is already installed.
const cors = require('cors');
app.use(cors())
The thing is when I change the content-type, I get a success response but it won't let me download the pdf.