title: How to download csv file using fast csv in node js
body: <p>I want to export my data into csv file so for that purpose i used <code>fast-csv</code> in node js. its working fine my code is </p>
  
  <pre><code>var csv = require("fast-csv");
  app.get('/file/exportToExcel', function(req, res) {
          var whereCondi = {
              'Id': req.query.id,
          }
          var response = {};
          table.find(whereCondi, function(err, tableData) {
              if (err) {
                  response.status = 400;
                  response.message = err.message;
                  res.send(response);
              } else {
                  var csvStream = csv.createWriteStream({headers: true}),
                  writableStream = fs.createWriteStream("code.csv");
                  writableStream.on("finish", function() {
  
                  });
                  csvStream.pipe(writableStream);
                  for (var i = 0; i &lt; tableData.length; i++) {
                      csvStream.write({allcodes: tableData[i].code});
                  }
                  csvStream.end();
  
              }
          });
      });
  </code></pre>
  
  <p>but the problem is its saving that csv file in my root folder i want to download that csv file when user click on export to excel please help me.</p>