I was using a request
module and that is deprecated now. It was useful to pipe the remote files without storing in server. So looking for an alternative solution of the same function with Node-fetch, GOT, Axios etc..
import request from 'request';
(req, res) {
return request(`http://files.com/image.jpg`)
.on('error', (err) => {
log.error('error fetching img url: %O', err);
res.status(500).end('error serving this file');
})
.on('response', (urlRes) => {
if (urlRes.statusCode === 304) return;
urlRes.headers['content-disposition'] = `inline;filename="${slug}"`;
})
.pipe(res);
}