I have two files a config.js and main.js I am storing api keys in my config.js like this
function getGoogleApiKey(){
return 'KeyGoogle';
}
function getApiKey(){
return 'keyApi'
}
function getApiKey2(){
return 'keyApi2'
}
module.exports = {
getGoogleApiKey,
getApiKey,
getApiKey2,
}
I would like to get specific keys from the config.js file when I need it. I want to use some keys on my main.js Here is my main.js.
const {config} = require('./config.js');
const googlePlaces = new GooglePlaces(config.getGoogleApiKey, 'json');
const awesome = new awesome(config.getApiKey);
I am note sure how to get the keys, I also tried it in this way but I get errors.
const {getGoogleApiKey, getApiKey, getApiKey2} = require('./config.js');
const googlePlaces = new GooglePlaces(getGoogleApiKey, 'json');
via Masnad Nihit
No comments:
Post a Comment