Prompt a csv file to download as pop up using node.js and node-csv-parser (node module)

后端 未结 5 1624
日久生厌
日久生厌 2020-12-23 18:15

Recently I have started working with node.js. While going through a requirement in one of my projects I am facing an issue where I should be able to write some data to a csv

5条回答
  •  心在旅途
    2020-12-23 18:33

    Manish Kumar's answer is spot on - just wanted to include a Express 4 syntax variant to accomplish this:

    function(req, res) {
      var csv = GET_CSV_DATA // Not including for example.
    
      res.setHeader('Content-disposition', 'attachment; filename=testing.csv');
      res.set('Content-Type', 'text/csv');
      res.status(200).send(csv);
    
    }
    

提交回复
热议问题