How can I create a text file easily in Meteor (Server Side) and download as a .txt file?
// On Server
if (Meteor.isServer) {
Meteor.methods({
'scan-db': function () {
// scan the DB for corrupted data
var allEntries = Jobs.find().fetch();
var report = "";
for ( let i = 0; i < allEntries.length ; i ++ ) {
if ( validate(allEntries[i]) == false ) {
report = report + allEntries[i].entryNumber + " has a problem" + "\n";
// used \n for line breaks in windows
}
return report; // a whole bunch of string
})
}
// On client
if (Meteor.isClient) {
Meteor.call("scan-db", function(err, res) {
if (res) {
downloadFile(res);
}
})
}
I am hoping to be able to download my result as a text file to save. Is there any easy way of doing this? I tried using meteorhacks:picker
but apparently the package is not working or Picker
returned undefined
despite importing it import { Picker } from 'meteor/meteorhacks:picker';