I have a Express.js backend that sends in-memory generated *.zip with *.docx files inside it. Zip is sent as a buffer. Backend sends data, frontend receives it. It's all good until that point.
The problem is that when I receive it at the frontend using axios I can't force browser to download it as a *.zip client-side so user can open it and use.
This is what I do on the frontend:
let formData = new FormData()
formData.append("data", JSON.stringify(this.data))
formData.append("template", this.template)
axios.post('http://localhost:3001/gen', formData, {
responseType: 'blob',
headers: {
'Content-Type': 'multipart/form-data'
}
})
.then(res => {
res.end( res.data, 'binary' );
})
but it's not downloading file as I wish. I'm not saving file anywhere on the server - I just create it on the fly in the memory and send it to the client.