How to download a file into a Buffer in Node.js?
https.get(url, (res) => {
const data = [];
res.on('data', (chunk) => {
data.push(chunk);
}).on('end', () => {
let buffer = Buffer.concat(data);
// Do something with the buffer
});
}).on('error', (err) => {
console.log('download error:', err);
});