0

I'm trying to retrieve a csv template that is in an API response. I am getting a 200 status and I can see the response data in the network tab of Chrome Dev tools. The response text is supposed to be the column headers in the csv file. But how do I actually get the csv file to either download or open in excel?

return request
    .get(url)
    .set('Content-Type', 'text/csv')
    .end(function (err, res) {
        if (res) {  
            // get csv template?
        }
    });

response looks like:

statusCode: 200
content-disposition: attachment; filename="template.csv"
header: {content-length: "100", content-type: "text/csv"}
type: text/csv
text: "First Name","Last Name","Email"
nerz
  • 337
  • 1
  • 5
  • 13
  • 1
    Please visit this answer https://stackoverflow.com/a/58716421/615274 might be useful for you – Mario Jul 28 '20 at 16:22
  • Does this answer your question? [Using javascript to download file as a.csv file](https://stackoverflow.com/questions/17564103/using-javascript-to-download-file-as-a-csv-file) – Vinay Jul 28 '20 at 16:38
  • But I don't know even how to access the response data to start to use it – nerz Jul 28 '20 at 16:59

0 Answers0