Return pdf file from webservice with Node.js

Asked

Viewed 189 times

2

Context of the Problem: There is an external webservice, which is not part of the domain of my application, which, when accessed directly via browser, takes the user to a uploading web page that handles the request according to the parameters passed in the url and later, returns a file. pdf directly in the browser view.

I am working on an application that aims to call that specific webservice and return a file. pdf generated by this for the user.

In order to try to get the file generated by the webservice, I tried to use the package request of npm as follows:

    var request= Meteor.npmRequire('request');
    request.get({
              url: this_nfse.link_nfse,  timeout: 1500, jar: true, encoding: 'binary'
            }
            , Meteor.bindEnvironment(function( error, response, body ){
      if(!error && response)
      {          
        //tratar resultado de acordo com o objetivo da aplicação
      }          
    }));

But what I get in the body object is the html page that makes the file generation request. pdf to webservice, not the file or representation of that itself.

Obs.: I tried using the native HTTP package of the media, but I got the same result.

Any help or tip will be very welcome, thank you very much.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.