Reputation: 82
I set an environment variable in Digitalocean with token, but I don't understand how to use it in the code. I scrolled through the docs, but didn't get anything. Can you please tell which path I should write or anything else what I should do?
Upvotes: 0
Views: 1456
Reputation: 765
To use variables in Digital Ocean using Functions over nginx runtime:
EXAMPLE
function main(event, context) {
require('dotenv').config();
const SECRET = process.env.VARIABLE_NAME;
}
Remember, is necessary to register the variable before access and use it.
Upvotes: 0
Reputation: 363
I would suggest using an environment function in your language of choice that searches the .env file or current global env and pull the variable that is available.
Example: for R, I can use Sys.getenv("MY_SECRET")
to pull the variable from DO.
Upvotes: 0