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

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -