I'm trying to make a file downloadable but it's not working, could you tell me where is my mistake ? Server-side :
app.get("/telechargement/propt", function (req, res) {
var propt = [];
testDb.find({}).sort({ createdAt: -1 }).exec(function (err, docs) {
var propt = docs;
var propt_xls = json2xls(propt);
fs.writeFileSync('propt_conv.xlsx', propt_xls, 'binary');
res.set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
res.download('propt_conv.xlsx');
});
});
testDb.find is just a noSQL resquest to my NeDB database.
AngualarJS-side :
$scope.exportXLS = function() {
$http.get("/telechargement/propt").then(function(response){
});
}
I guess the mistake is AngularJS-side but I don't know what to do with the response in download case.
HTML-side :
<a href="#" ng-click="exportXLS();">DL</a>
via Tewan
No comments:
Post a Comment