CodeIgniter Forums
unable to download the csv file in via rest api - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forum-31.html)
+--- Thread: unable to download the csv file in via rest api (/thread-80394.html)



unable to download the csv file in via rest api - 2k10cs86 - 10-27-2021

Hello,
I'm trying to download the CSV content file using the REST API in Codeigniter 4 but it not working, I'm fetching the data from the database which I need to download via rest API.
In the controller I found this:
return $this->response->download('test.csv', $data); // $data is string

Front in angular:
const headers = new HttpHeaders().append('responseType', 'blob');
this.http.get(path, { headers }).subscribe(
  (res) => {},
  (error) => {console.error(error)}
);

But not working, am I missing something?

Please guide me.