How to get a variable from a file to another file in Node.js

前端 未结 2 598
逝去的感伤
逝去的感伤 2020-12-07 11:11

Here is my first file:

var self = this;
var config = {
    \'confvar\': \'configval\'
};

I want this configuration variable in another file,

2条回答
  •  执笔经年
    2020-12-07 11:51

    File FileOne.js:

    module.exports = { ClientIDUnsplash : 'SuperSecretKey' };
    

    File FileTwo.js:

    var { ClientIDUnsplash } = require('./FileOne');
    

    This example works best for React.

提交回复
热议问题