I'm trying to set GLOBAL variable available across all modules of Node.js app.
module.exports = app => {
app.get('/config', async (req, res) => {
.....
const { data } = await axios.get('.....')
app.locals.MY_CONFIG = data.config
Then in other module:
module.exports = app => {
app.post('/getData', async (req, res) => {
.....
const { data } = await axios.get('.....')
if (app.locals.MY_CONFIG.prop1 === true) {
.....
} else {
.....
}
Will this line cause memory leaks every time the route is called?
app.locals.MY_CONFIG = [data.config]
in other words will this cause an issue:
app.locals.MY_CONFIG = [data.config]
app.locals.MY_CONFIG = [data.config]
app.locals.MY_CONFIG = [data.config]
app.locals.MY_CONFIG = [data.config]
...
if (app.locals.MY_CONFIG.prop1 === true)there's no danger of this so far