This module is a wrapper around request module.
It provides progress
event that shows current of the download
like it's speed, ETA, percentage etc.
You have to install request module:
npm install request --save
Then you need to install this module:
npm install request-download-info --save
const request = require('request')
const RequestInfo = require('request-download-info')
const fs = require('fs')
let info = new RequestInfo(
request('http://releases.ubuntu.com/16.04.3/ubuntu-16.04.3-desktop-amd64.iso')
)
info.on('progress', status => {
console.log(status)
}).pipe(fs.createWriteStream('ubuntu.iso'))
The above example downloads Ubuntu iso from official page, to ubuntu.iso
in
current directory and prints status of download each second (by default).
See Documentation here