I\'m using a spring boot backend and my api uses a service to send data via an OutputStreamWriter. I can download this in Angular 2 using a click event like so:
Looks like you just need to parse the body of the response i.e
let parsedResponse = data.text();
this.downloadFile(parsedResponse);
Also I would recommend you use FileSaver to download files as even in 2016 there does not seem to be a standard way to do this across browsers.
let blob = new Blob([data], { type: 'text/csv' });
saveAs(blob, "data.txt");
For a more in depth guide check here
I use FileSaver
, too. If you have extension on client side, you can see that it will work properly for CSV
files. You just need to add extension manually:
FileSaver.saveAs(res, 'export' + extension);