I added node and express to my project with dotenv to hide the API KEY I am using.
Everything works fine but I cannot see how to pass the process.env.API_KEY to be used app.js file.
index.js
const express = require('express');
const app = express();
require('dotenv').config();
console.log(process.env.API_KEY);
app.listen(3000, () => console.log('Starting server: http://localhost:3000'));
app.use(express.static('public'));
app.js
document.addEventListener('readystatechange', (event) => {
if (event.target.readyState === 'complete') {
initApp();
}
});
const initApp = () => {...}