dowbload created file in node js code example
Example 1: express download file
app.get((req, res, next) => {
res.download('/file/to/be/downloaded.ext');
res.status(200);
});
Example 2: download a file nodejs
const http = require('http');
const fs = require('fs');
const file = fs.createWriteStream("file.jpg");
const request = http.get("http://i3.ytimg.com/vi/J---aiyznGQ/mqdefault.jpg", function(response) {
response.pipe(file);
});