I have a node js web server, and hen ever I wake up the server, after MongoDatabase connects, it sends this to my console
MongoClient {
_events: [Object: null prototype] { newListener: [Function] },
_eventsCount: 1,
_maxListeners: undefined,
s: {
url: 'mongodb+srv://cookie:lmTMc*********@logs.4kn9o.mongodb.net/Logs?retryWrites=true&w=majority',
options: {
servers: [Array],
...
It sends this to my console, which because of where I host (repl.it), in some cases, the console is publically viewable. This is a problem because it shows my user password. How can I remove this log?
Here is the code for connecting to the database
let client, url, database, collection, query;
async function mongoPrep() {
try {
url = process.env.MONGOURL;
client = new MongoClient(url, {
useUnifiedTopology: true
});
await client.connect();
database = client.db("Data");
collection = database.collection("Data");
query = {
name: "data"
};
await getData();
} catch (error) {
console.log(error);
} finally {
console.log("Mongo Connection Success");
}
}
I found the problem. I was had console.log(connection) somewhere. I need to do a better job at reviewing my code (note i found this a while ago, but adding the answer now)