I have the following (simple) node module:
var json2xls = require('json2xls');
var fs = require('fs');
module.exports = function (router, mongoose) {
router.route('/client/toExcel')
.post(function (req, res) {
var obj = req.body.data;
var xls = json2xls(obj);
fs.writeFileSync('data.xlsx', xls, 'binary');
res.download('data.xlsx');
});
return router;
};
Now when i call this from my frontend. The node server creates the file however it sends back the file but as text and not as a downloadable file here is a screenshot at my console:
Can anyone tell me what im doing wrong?
Here is a image of my request: