Reputation: 53850
I run an Express app like this inside app.js
file:
var app = express();
Now I can set some variables like this:
app.set('host', 'myhost')
I also have api.js
module and I want to access this host variable from the root app.js
file. How can I do this?
Upvotes: 1
Views: 1173
Reputation: 2938
In your app.js
file:
module.exports = app;
In your api.js
file:
app = require("./app.js")
host = app.get('host');
Upvotes: 2