I know how this can be done in php, but in javascript i don't know that much, but i will find the best possible way to explain myself. let say i have a schema called setting schema where i do save some api keys and it have this result
{
"_id": "5d7f77d620cf10054ded50bb",
"dimension": 166,
"stripe": "Axd3232wed22342214r2",
"paystack": "fiasfd321r23r3vb.dfaedw1",
}
so i design a setting.js where i called out all this value's using the module.export
const express = require('express');
const mongoose = require('mongoose');
const Settings = require('../../models/Settings');
module.exports = {
dimension : function getDimension() {
return Settings.find({_id : "5d7f77d620cf10054ded50bb"},{dimension:1}, (err, res) => {
if(err) throw new Error(err.message, null);
const holder = res[0].dimension;
return holder;
});
},
stripe: function getStripe() {
return Settings.find({_id : "5d7f77d620cf10054ded50bb"},{stripe:1}, (err, res) => {
if(err) throw new Error(err.message, null);
const stripe = res[0].stripe;
return stripe;
});
},
paystack: function getPaystack() {
return Settings.find({_id : "5d7f77d620cf10054ded50bb"},{paystack:1}, (err, res) => {
if(err) throw new Error(err.message, null);
const paystack = res[0].paystack;
return paystack;
});
},
}
so all i want is if i import this setting.js and i also import
const settings = require(./settings)
const dimension = settings.dimension
if i console.log dimension all i get is [Function: getDimension]
instead of
166
all i want is i want this value to be available globally within my application