linkedin-node-databases
linkedin-node-databases copied to clipboard
TypeError: client.isConnected is not a function
I get the folllowing error when I run the code in VS Studio and try to connect to MongoDB.
TypeError: client.isConnected is not a function at MongoBackend.max (/Users/.../node-databases/maxcoin/services/backend/MongoBackend.js:40:14)
Do you have a suggestion for how I can make this code work? It seems that client.isConnected has been discontinued.
A quick solution is to use "mongodb": "^3.6.2" inside package.json
So it looks like isConnected is deprecated. All I needed to do is transform it into a try catch, with the catch being if it didn't successfully connect. The other thing that you don't need at that point is the const client because it only gets used for the isConnected function, so you can just do an await like you do with the disconnect at that point.