i have added some variables in my .env file.
But in my js file, i cant access this How can i do this?
I am using node js template for shopify app.
i have added some variables in my .env file.
But in my js file, i cant access this How can i do this?
I am using node js template for shopify app.
The .env file is a separate file, distinct from your backend .js file. It’s simply named .env .
Inside the .env file, you can define your variables like this:
PORT=3000
now, within your backend .JS file, you can call your environment variables like so:
const port = process.env.
PORT console.log (port) // 3000
If you are using glitch.com , I think the .env file is applied automatically. If not, you may need to use an npm module called “dotenv” to read in your variables.
If this was helpful, hit the like button and accept the solution.
Thanks