xero
xero copied to clipboard
Generate & Download PDF of Invoice
Hey I am trying your code to generate and download PDF of particular invoice ID, but I am facing some problem. My Code like this:-
var xero = new Xero(CONSUMER_KEY, CONSUMER_SECRET, RSA_PRIVATE_KEY); var invoiceId = xxxxxxxxxxxxxxxxxxxx; var req = xero.call('GET', '/Invoices/' + invoiceId);
req.setHeader('Accept', 'application/pdf'); req.on('response', function(response) { console.log("Response"); var file = fs.createWriteStream(invoiceId + '.pdf'); response.pipe(file); console.log("Response after cerateing File"); }); req.end();
Both console.log messages printed but doesn't return anything and Browser continuous loading. Is there any mistake?? How should I Download pdf of invoice??