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
Post a Comment