hi,
I would like to make a settings variable e.g. to store the host to be available on both the server and client, how can I do that the best way?
- export a collection, then I always have to code
QRSConfig.findOne();
- or just do
export const senseConfig = QRSConfig.findOne();
thanks
–> somehow I get undefined errors on the client if I want to read the exported constant
export const QRSConfig = new Mongo.Collection('QRSConfig');
var _senseConfig = {
"host": '2008ENT', //window.location.hostname, on client side
};
if (Meteor.isServer) {
QRSConfig.remove({});
QRSConfig.insert(_senseConfig);
}
export const senseConfig = QRSConfig.findOne();
Thank you for helping out… I am learning meteor off course, so I am making my code each day more flexible
The issue now is tons off errors. I know this is because of the async stuff… But how do you guys handle this? my urls are not generated now…
var config = QRSConfig.findOne();
Template.generation.helpers({
appSettings: function() {
console.log('client generation helper: get app table, the config used to generate the URLs to Sense: '+config);
return {
...
fields: [
{ key: 'name', label: 'App' }, {
key: 'id',
label: 'Guid',
fn: function(value) {
return new Spacebars.SafeString('<a href=http://' + config.host + '/' + config.virtualProxyClientUsage + '/sense/app/' + value + ' target="_blank">' + value + '</a>');
No, I still have an issue: the host is undefined now… (so the helper is too fast I gues…)
The QRSConfig loaded on the client looks like this (with msavin:mongol)
PS: I use autopublish, it is just a demo app for my company.
All about settings variables
1 Like
yeah you are right… I had that one on my todo list… so I should give it priority. Thank you very much… I used the wrong technique…
On the other hand. I use autoform and an if statement in the template so consultants can easily setup the environment if something goes wrong.
So I prefer to put it in a database and use the form if possible?
I also wonder why my helper does not render the url eventually… A collection is reactive so…