To create a configuration in nodejs.
I will create a folder as config a file naming as config.js and later I will use this file wherever required as below
Example of config.js
module.exports = {
proxyURL: 'http://url:port',
TWITTER: {
consumerkey: 'yourconsumerkey',
consumerSecrete: 'yourconsumersecrete'
},
GOOGLE: {
consumerkey: 'yourconsumerkey',
consumerSecrete: 'yourconsumersecrete'
},
FACEBOOK: {
consumerkey: 'yourconsumerkey',
consumerSecrete: 'yourconsumersecrete'
}
}
Then if i want to use this config file somewhere
I will first import as below
var config = require('./config');
and I can access the values as below
const oauth = OAuth({
consumer: {
key: config.TWITTER.consumerkey,
secret: config.TWITTER.consumerSecrete
},
.
.
.
.
.
});
That’s all enjoy 🙂
Author Profile
![PREM KUMAR](https://pkworlz.com/wp-content/uploads/2021/12/WhatsApp-Image-2021-06-24-at-8.47.49-PM-min-150x150.jpeg)
- Hey Its..! Tech Lover , Ionic, Angular, Typescript, Dotnet Core, Node, Like Opencv, AI, ML, Robotics, Iot, Love Music, Cooking, Girls, Innovation