How to convert the following method to an async method (syntax-wise):
const download = function(url, dest, callback){
request.get(url)
.on('error', function(err) {console.log(err)} )
.pipe(fs.createWriteStream(`./voices/${dest}`))
.on('close', callback);
};
This syntax isn't correct:
async function download(function(url, dest, callback)){
request.get(url)
.on('error', function(err) {console.log(err)} )
.pipe(fs.createWriteStream(`./voices/${dest}`))
.on('close', callback);
};
because function(url, dest, callabck)
isn't recognized as a function.