I have this error when I tried use sleep for a loop
Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.
My Code:
fs.readdir(directory, (err, files) => {
if (err) {
console.log("error get file");
}
if(files.length > 0) {
for (var i = 0; i <files.length; i++) {
Fiber(function()
{
setTimeout( function()
{
Meteor.call('mymethodfile', files[i]);
}, 1000 );
}).run();
}
}
});
in the same file
Meteor.methods({
'mymethodfile':function(arch)
{
var file=arch;
console.log(file);
getdata(file);
}
})
Please help me