To get a variable from a file to another file in Node.js, we use modules.
For instance, we write
module.exports = { clientIDUnsplash: "SuperSecretKey" };
to export an object with the clientIDUnsplash
property in unsplash.js.
Then we write
const { clientIDUnsplash } = require("./unsplash");
to call require
to require the unsplash.js file and get the clientIDUnsplash
property from the returned object.