Answer the question
In order to leave comments, you need to log in
How to know if data is being transferred or not?
To connect to the database, there is a preliminary inspection for the presence of all the necessary parameters. The condition is written, if something is missing, then
an error will be displayed:
const {DB_NAME, DB_USER, DB_PASSWORD, DB_HOST, DB_PORT} = process.env;
const somethingIsNotDefined = [DB_NAME, DB_USER, DB_PASSWORD, DB_HOST, DB_PORT].some((it) => it === undefined);
if (somethingIsNotDefined) {
throw new Error(`One or more environmental variables are not defined`);
}
DB_NAME=buy_and_sell
DB_USER=user
DB_PASSWORD=password
DB_HOST=localhost
DB_PORT=5432
{"level":50,"time":1620121263715,"pid":12590,"hostname":"Poly-Extensa-5230","name":"base-logger","msg":"An error occured: password authentication failed for user \"andrew\""}
Answer the question
In order to leave comments, you need to log in
Installed the dotenv library, used it as it should and it worked
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question