meteor - MeteorJS: accessing window global scope in server -
i have small app has file called cities.js. file has variable so:
window.cities = ["city a", "city b", "city c"];
how access window object in meteorjs if executing server-side? or how can load in file window.cities variable available?
the error keep getting referenceerror: window not defined
here code (server.js):
meteor.startup(function(){ if(cities.find().count() === 0) { len = window.cities.length; for(i = 0; < len; i++) { c = window.cities[i]; c = c.split(", ").join("+"); citites.insert({city_name: c}) } } });
you can't. window variable referring browser window of client , not in way part of meteor's namespace. need save data collection while on client, can read on server.
Comments
Post a Comment