juicycleff / casbin-mongodb-adapter

Pure MongoDB adapter for Casbin
MIT License
9 stars 14 forks source link

How to fix Error: The "url" argument must be of type string. Received undefined #7

Closed hoanghiep1x0 closed 3 years ago

hoanghiep1x0 commented 4 years ago
const { MongoAdapter } = require('casbin-mongodb-adapter');

let uri = 'mongodb://192.168.99.100:27017,192.168.99.101:27017,192.168.99.102:27017/casbin';

const connect = (options) => {

 const adapter = await MongoAdapter.newAdapter({
      uri: uri ,
      option: {
        db: options.dbParameters(),
        server: options.serverParameters(),
        replset: options.replsetParameters(options.repl)
      }
    })

  return adapter;
}

RUN return error :

(node:11963) UnhandledPromiseRejectionWarning: Error: The "url" argument must be of type string. Received undefined at MongoAdapter.open (/Users/iadm/Project/microservice/authorization/node_modules/casbin-mongodb-adapter/build/main/lib/adapter.js:162:19) at processTicksAndRejections (internal/process/task_queues.js:97:5) at async Function.newAdapter (/Users/iadm/Project/microservice/authorization/node_modules/casbin-mongodb-adapter/build/main/lib/adapter.js:35:9) at async EventEmitter.<anonymous> (/Users/iadm/Project/microservice/authorization/src/config/db/mongo.js:15:21) (Usenode --trace-warnings ...to show where the warning was created)

hsluoyz commented 4 years ago

@juicycleff

juicycleff commented 3 years ago

@hsluoyz this might be some issue with mongo dependency. A fix is coming

17bit commented 3 years ago

@hoanghiep1x0

 const adapter = await MongoAdapter.newAdapter({
      uri: uri ,
       db: options.dbParameters(),
       server: options.serverParameters(),
       replset: options.replsetParameters(options.repl)

    })

Use this.