How to fix Error: The "url" argument must be of type string. Received undefined
hoanghiep1x0 opened this issue · 3 comments
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) (Use
node --trace-warnings ...to show where the warning was created)
@hsluoyz this might be some issue with mongo dependency. A fix is coming
const adapter = await MongoAdapter.newAdapter({
uri: uri ,
db: options.dbParameters(),
server: options.serverParameters(),
replset: options.replsetParameters(options.repl)
})
Use this.