my (.env file) variables are not reading in Nestjs, how do I format it in my VSC editor to execute it. Appreciate anybody could help or advise on this. Thank you guys
PORT="3000"
API_PREFIX="/api/v1"
#Rabbit MQ
RABBITMQ_CONN_STRING="amqp://guest:guest@localhost:8888/"
RABBITMQ_Q_NAME="hcert-root-message"
# DB
MONGO_URL ="mongodb://localhost/jcerts-backend"
# Passport-JWT
JWT_SEC="kepler-jwt-secret"
# Mailer
AWS_ACCESS_KEY_ID= #
AWS_SECRET_ACCESS_KEY= # AWS key for SES
BASEURL= "http://localhost:3000"
# Smart Contracts
#ropsten infura
PROVIDER_HTTP= https://ropsten.infura.io/v3/63de3b382a7c4d30954ed8bf912xxxxx
INFURA_VERSION="v3"
INFURA_ID="63de3b382a7c4d30954ed8bf91xxxxx"
# OTP Required
OTP_REQUIRED_SIGN_IN = false
OTP_REQUIRED_SIGN_UP = true
OTP_REQUIRED_SIGNING = true
OTP_REQUIRED_NOAISSUE = true
# Wallet ropsten
WALLET_PRIV = "e70694578f637de71fc4dcd68a1d4ba418db6ebc61f9072ea52e4bxxxxxxxxx"
WALLET_ADDR = "0xEB8EaC9396267DEbe493fFc80xxxxxxxxx"
VALUE = "0.5"
GAS_PRICE_PREMIUM_PCT="10"
GAS_LIMIT="70000"
GAS_LIMIT_DOCSTORE="1500000"
ISSUEDOC_NETWORK = "ropsten"
# ropsten
DOCSTORE_FACTORY="0xb539d81F709b23D1039A19596AA19xxxxxxxxxx"
Click at the bottom where it says JSON
Type in env and select Environment Variables
You also need to update your env file:
='sIf for some reason this still isn't working or Environment Variables isn't an option, install this VS Code extension:
Name: ENV
Id: irongeek.vscode-env
Description: Adds formatting and syntax highlighting support for env files (.env) to Visual Studio Code
Version: 0.1.0
Publisher: Jakka Prihatna
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=IronGeek.vscode-env
Finally, if all of this doesn't work, make sure your .env file is in the correct folder.
If Nestjs doesn't come with dotenv, you'll need to set it up yourself
Check url param where i used env variable, by this way you can get and use variable value. it will help you out.
var restaurants_id = 1;
restaurants_name = "hello";
restaurants_code = 2903483;
$.ajax({
type: 'post',
url: ***'{{env("DB_HOST")}}',***
data: {
'restaurants_id': restaurants_id,
'restaurants_name': restaurants_name,
'restaurants_code': restaurants_code
},
success: function(data) {
console.log(data);
}
});