node.js - Pdfkit node + express Download PDF -


i'm triying download pdf when click on button. response de api node , if try on postman works ok , can save pdf, when call api express don't know how call it.

node function

function generarpdf(req, res){   let presupuestoid = req.params.id;   let doc = new pdf();   res.setheader('content-disposition', 'attachment; filename="' + presupuestoid + '.pdf"');   res.setheader('content-type', 'application/pdf');   doc.font('times-roman').fontsize(12).text(presupuestoid,100,100)   doc.pipe(res);   doc.end();  } 

route

api.get('/generarpdf/:id', md_auth.ensureauth, presupuestocontroller.generarpdf); 

express service

generatepdf(token, id){    let headers = new headers({   'content-type':'application/json',   'authorization':token   });      return this._http.get(this.url+'generarpdf/' + id, {headers: headers})            .map(res => res.json()); } 

express view

oncrearpdf(presupuestoid){       this._presupuestoservice.generatepdf(this.token, presupuestoid).subscribe(         response => {             if (!response) {                console.log('error')             }             ///?¿?¿??¿?¿???¿?¿?¿?¿         },         error => {             var errormessage = <any>error;              if (errormessage != null) {                 var body = json.parse(error._body);             }         })  } 


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -