When i load my custom made file globally, it is not loaded properly and returns an empty object:
const msgq = require('../db/message_queue.js');
var getList = async(url) => {
console.log(msgq);
...
}
However, if i load locally inside the function, it works as I expected. What is the reason behind this?:
var getList = async(url) => {
const msgq = require('../db/message_queue.js');
console.log(msgq);
...
}
Though, the weird thing is that in other parts of my code, i declared it globally and used it with no problem...
running on ExpressJS