JavaScript Node.js Basics Create a Command Line Weather Application Retrieving Data - Solution

.env Vs. api.json

Prior to this lesson I've been storing API keys in a hidden .env file and using process.env.API_KEY to access it.

Is there a benefit to using api.json over .env? Is one approach more secure than the other?

1 Answer

Heidi Fryzell
.a{fill-rule:evenodd;}techdegree seal-36
Heidi Fryzell
Front End Web Development Treehouse Moderator 20,612 Points

Hi there,

Thanks for reaching out. I honestly don't know the answer to your question, it goes it little beyond my present experience level. I did do a Google search to try and understand what you were asking and this article might be helpful:

It talks about why you should use environment variables with a .env file over a config.json file.

I hope this helps in some way and happy coding! Heidi

Thanks Heidi , the article is a well written article on working with .env

Up until this tutorial I thought .env was the standard for hiding sensitive information. I'm familiar with using .env, I'm just wondering if using api.json like Andrew did is a good convention for modern day? I've never seen it done like this before.

Most frameworks seem to use .env. I am somewhat new to this as well. Thanks!