#How to use Remote Auth using mongodb

8 messages · Page 1 of 1 (latest)

clear lion
#

How to connect to mongodb database using this .

const { Client, RemoteAuth } = require('whatsapp-web.js');

// Require database
const { MongoStore } = require('wwebjs-mongo');
const mongoose = require('mongoose');

// Load the session data
mongoose.connect(process.env.MONGODB_URI).then(() => {
    const store = new MongoStore({ mongoose: mongoose });
    const client = new Client({
        authStrategy: new RemoteAuth({
            store: store,
            backupSyncIntervalMs: 300000
        })
    });

    client.initialize();
});
 
ionic tundra
#

Experience in NodeJs and MongoDB is required

tranquil jasper
#

how to check session is exist or not in mongodb?

civic garden
#

C:\Users\COSMICBUG\Desktop\Whatsapp BOT\node_modules\mongoose\lib\drivers\node-mongodb-native\connection.js:206
throw new MongooseError('The uri parameter to openUri() must be a ' +
^

MongooseError: The uri parameter to openUri() must be a string, got "undefined". Make sure the first parameter to mongoose.connect() or mongoose.createConnection() is a string.
at NativeConnection.createClient (C:\Users\COSMICBUG\Desktop\Whatsapp BOT\node_modules\mongoose\lib\drivers\node-mongodb-native\connection.js:206:11)
at NativeConnection.openUri (C:\Users\COSMICBUG\Desktop\Whatsapp BOT\node_modules\mongoose\lib\connection.js:755:34)
at Mongoose.connect (C:\Users\COSMICBUG\Desktop\Whatsapp BOT\node_modules\mongoose\lib\index.js:404:15)
at Object.<anonymous> (C:\Users\COSMICBUG\Desktop\Whatsapp BOT\index.js:15:10)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47

Node.js v18.16.0

civic garden
#

@ionic tundra Bro can u pls help me?

civic garden
#

@tranquil jasper Can you help me?