所以,我有下面的代码:
const { Database, aql } = require("arangojs");
const db = new Database({·
url: 'http://127.0.0.1:8529'
} );
db.useBasicAuth('root', 'password1')
(async function() {
const now = Date.now();
try {
const cursor = await db.query(aql`RETURN ${now}`);
const result = await cursor.next();
} catch (err) { console.log(err) }
})();
这给了我一个错误:
TypeError: db.useBasicAuth(...) is not a function
驱动程序的版本是:
"arangojs": "^6.3.0"
有什么想法吗?
答案 0 :(得分:3)
调用db.useBasicAuth后缺少分号。下一行的立即执行功能使“不再使用分号”语法变得混乱。它尝试使用下面一行的功能作为参数运行useBasicAuth函数的结果,但是useBasicAuth不返回函数。
这将消除类型错误:
const { Database, aql } = require("arangojs");
const db = new Database({·
url: 'http://127.0.0.1:8529'
} );
db.useBasicAuth('root', 'password1');
(async function() {
const now = Date.now();
try {
const cursor = await db.query(aql`RETURN ${now}`);
const result = await cursor.next();
} catch (err) { console.log(err) }
})();