title: How to send buffer data in express?
body: <p>I am trying create and send an excel file to client. Client should download the file via ajax request, because I need filter parameters.</p>
  
  <p>I am using excel4node package to create an excel file.</p>
  
  <p>I write the code below and it's working for now but i am suspicious what if I will have data bigger than buffer. Is this the right way of using buffer? (please check the line with writeToBuffer method)</p>
  
  <pre><code>    const xl = require('excel4node');
  
      const excelCreator = function (data) {...}
  
      app.post('/api/excel', jsonParser, (req, res) =&gt; {
  
        let reqObj = {
          method: 'post',
          url: apiUrl + '/MemberService';,
          headers: {
            'Content-Type': 'application/json'
          },
          data: req.body
        };
  
        axios(reqObj)
          .then(response =&gt; {
            res.body = responseHandler(response); // a helper function to set res object
  
            let data = res.body.Data;
  
            res.setHeader('Content-Disposition', 'attachment; filename=' + 'excel.xlsx');
            res.type('application/octet-stream');
            res.body.Data = null;
  
            excelCreator(data).writeToBuffer().then(function (buffer) {
              res.body.Data = buffer;
              res.send(res.body);
            });
  
          })
          .catch(...);
      });
  </code></pre>