kharandziuk
kharandziuk

Reputation: 12880

arangoDb + nodejs: db.useBasicAuth(...) is not a function

So, I have code bellow:

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) }
})();

which gives me an error:

TypeError: db.useBasicAuth(...) is not a function

version of the driver is:

"arangojs": "^6.3.0"

Any ideas?

Upvotes: 1

Views: 401

Answers (1)

Henry Mueller
Henry Mueller

Reputation: 1327

There is a missing semicolon after call to db.useBasicAuth. The immediate execution function on the next line confuses the "no semicolons anymore" syntax. Its trying to run the result of the useBasicAuth function with the function on the following line as the parameter, but useBasicAuth does not return a function.

This will get rid of the type error:

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) }
})();

Upvotes: 2

Related Questions