I am loading config.json
file using nconf
like below:
nconf.file({ file: '../config.json' });
. I am using a property in that config file which I can print on console and it works:
console.log('mailhost: '+ nconf.get('mailhost'));
But my requirement is to have an object where I can dynamically put nconf properties like so:
var mailConfig = {
"mailhost": nconf.get('mailhost')
};
console.log('mailConfig: '+ JSON.stringify(mailConfig));
The above doesn't work as it prints empty object on console.
However, if I happen to load the config.json file using node like so:
var config = require('../config.json');
And use it to do exact same I did with nconf then it works well:
var mailConfig = {
"mailhost": config.mailhost
};
console.log('mailConfig: '+ JSON.stringify(mailConfig));
What am I missing?