node.js - 如何解决 mongodb 连接中发生的意外令牌错误?
问题描述
我已经编写了假设连接到 mongo DB 的代码。但是在运行代码时出现以下错误;
代码 -
// Create a new MongoClient
//const client = new MongoClient (uri);
function run () {
const uri =
'URI value ';
const client = new MongoClient(uri);
try {
// Connect the client to the server
await client.connect ();
// Establish and verify connection
await client.db ('snapp_transactions').command ({
ping: 1
});
log.info ('Connected successfully to server');
} finally {
// Ensures that the client will close when you finish/error
await client.close ();
}
}
ERROR MESSAGE -
ERROR: Unexpected token {
internetexplorer
C:\Users\MOHAS076\SBC-trp-web-test-automation\src\step-definitions\Web\when.js:88
} catch {
节点版本 - 8.12
解决方案
推荐阅读
- c# - 在令牌不再使用后调用 CancellationToken 注册的回调
- java - Java Play 框架“java.util.NoSuchElementException:调用 setControllerComponents...”
- python - AttributeError:“str”对象在最后一行没有属性“write”错误,需要洞察力
- go - 无法调用 go-gin 中间件
- tensorflow - 为什么 Bert 转换器使用 [CLS] 令牌进行分类,而不是对所有令牌进行平均?
- python - 从同一网络上的其他设备连接到 Flask Server
- go - 在 Linux/macOS 终端中从 Go 程序打印并使用回车时清除其余行
- python - 从另一个类中的函数创建一个类的实例
- javascript - 使用jquery加载页面后如何更改图标的颜色
- ruby-on-rails - 如何使用钩子/回调创建延迟作业作业?