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
  • 8,658
  • 22
  • 77
  • 159

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,411
  • 2
  • 6
  • 18