proprytr Profile picture
7 Apr, 8 tweets, 2 min read
how to hide your secret infos, in #javascript ? 🤫

what you will need?
[ dotenv ] : it's a dependency that loads environment variables from '.env' files into process.env,

now, what is environment variables and process.env?
"environment variables": are variables whose definition is defined outside of the program, using name=value pairs syntax, typically through the functionality built into the operating system or microservice,
& which gets available for reference into your program as your needs.
"process.env": is a property in nodejs of process object, that returns an another object containing the user environment.
so, now we are done with some definitions lets come to the point for which this post was created,

first install the dotenv dependency into your working project directory by issuing:
=> npm install dotenv Image
since, dotenv is added to your package.json file, now
create a '.env' file in you working project directory &
write down your secret sauces you have to hide from masses 🙊 in name="value pairs". Image
then where you want this secret to have, go to that file and first access the dotenv's config functionality as show in pic below and use your secret as you wanted it to Image
woah 😊 you have finally achieved your mission, you can now console log to see your suceess. Image
@threadreaderapp roll it.

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with proprytr

proprytr Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!