I’m trying to access a global variable that I set in server/main.js within a meteor.method inside a package and it’s returning undefined
. Here’s my code:
/* server/main.js */
myGlobalVariable = true;
/* packagedir/methods.js */
Meteor.startup(function () {
Meteor.methods({
myMethod: function() {
console.log(myGlobalVariable);
}
});
});
/* packagedir/package.js */
Package.onUse(function (api) {
api.versionsFrom('0.9.4');
api.addFiles('methods.js', 'server');
api.export('myGlobalVariable', 'server');
});
myGlobalVariable always returns undefined
within the package. What am I missing?