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

后端 未结 5 1608
日久生厌
日久生厌 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:38

    Check out this answer: Nodejs send file in response

    Basically, you don't have to save the file to the hard drive. Instead, try sending it directly to the response. If you're using something like Express then it would look something like this:

    var csv = require('csv');
    req.get('/getCsv', function (req, res) {
        csv().from(req.body).to(res);
    });
    

提交回复
热议问题