javascript - NodeJS download csv file to buffer -


i'm tying download small csv , need store in variable before process:

var http = require('http');  var csvdata; var request = http.get('http://url', function(response) {   response.pipe(csvdata); }); request.end(); 

response.pipe() works file stream, how can store response csvdata var?

just create listener data , end events:

var http = require('http');  var csvdata = ''; var request = http.get('http://url', function(response) {     response.on('data', function(chunk) {         csvdata += chunk;     });     response.on('end', function() {         // prints full csv file         console.log(csvdata);     }); }); 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -