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

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

    Following solution is for Express

    Express is evolved, instead of setting attachment and content type header, directly use attachment api http://expressjs.com/4x/api.html#res.attachment

    Note: attachment() don't transfer the file, it just sets filename in header.

    response.attachment('testing.csv');
    csv().from(data).to(response);
    

提交回复
热议问题