From 502de9b05a8bfc2a89d9124e402e006aa51b1c37 Mon Sep 17 00:00:00 2001 From: NyxiumYuuki Date: Fri, 28 May 2021 08:52:05 +0200 Subject: [PATCH] Add check client --- backend/service-authentication/mongodbConnect.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/service-authentication/mongodbConnect.js b/backend/service-authentication/mongodbConnect.js index 3c6db28..57643a1 100644 --- a/backend/service-authentication/mongodbConnect.js +++ b/backend/service-authentication/mongodbConnect.js @@ -6,7 +6,9 @@ let db; module.exports = { connectToServer: function( callback ) { MongoClient.connect( uri, { useNewUrlParser: true, useUnifiedTopology: true }, function( err, client ) { - console.log('mongodb-authentication-checkConnection'+client.isConnected()); + if(err) throw err; + console.log('mongodb-authentication-checkConnection'+client===undefined); + if (client !== undefined) console.log(client.isConnected()); db = client.db(config.mongodbDatabase); return callback( err );