0

In my Node Express app I have created a variable in app.js as shown below:

let accounts = [checkingAccount, savingAccount] 

Now, I have a separate file called account.js (Not a route) just a class file. And I want to access the accounts array. How can I do that?

john doe
  • 9,220
  • 23
  • 91
  • 167

1 Answers1

2

in your app.js use export

module.exports.accounts = ["checkingAccount", "savingAccount"];

and then in your account.js

accounts = require("./app.js");
Sven.hig
  • 4,449
  • 2
  • 8
  • 18