download binary files in express

Solutions on MaxInterview for download binary files in express by the best coders in the world

showing results for - "download binary files in express"
Gianluca
26 Mar 2016
1var options = {
2    method: 'GET',
3    host: 'localhost',
4    port: port,
5    path: '/file'
6  };
7
8var request = http.request(options, function(response) { 
9  var data = []; 
10
11  response.on('data', function(chunk) { 
12    data.push(chunk); 
13  }); 
14
15  response.on('end', function() { 
16    data = Buffer.concat(data); // do something with data 
17  }); 
18}); 
19
20request.end();
21