I am trying to download a file from my express js app :
const response = await Axios({
method: 'GET',
url: url,
responseType: 'stream'
})
However rather than doing this right after :
response.data.pipe(Fs.createWriteStream(path))
I want to send the response to my js client that requested my express js app with ajax, so that the file will directly be downloaded from my browser (client side) instead of server-side.
Any solution ?
You can pass the express response object to the pipe method
response.data.pipe(res);