I have a node.js api and have a requirement to have a config file that is fetched every 5 minutes. This config file is used throughout the application. I’ve tried the below, but the value always results in the initial value
var config = {};
refreshConfig => () = {
try {
let response = fetch(some network call);
config = response;
} catch e {
console.log(e);
}
}
setInterval(refreshConfig, 5*60*1000);
module.exports = config;
The scheduled process runs, but if I require the variable in any other file, the value is always {}