I am trying to get the documents from an ArangoDb database collection , from a Vuejs application. When I run the code below in a node console, it works fine.
Database = require('arangojs').Database;
aqlQuery = require('arangojs').aqlQuery;
const db = new Database();
db.useBasicAuth('root', 'degfra');
db.useDatabase('mydb');
let collection = db.collection('firstCollection');
db.query(aqlQuery`
FOR doc IN ${collection}
SORT doc.value ASC
RETURN doc._key
`).then(
cursor => cursor.all()
).then(
keys => console.log('All keys:', keys.join(', ')),
err => console.error('Failed to execute query:', err)
);
}
But when I run it from the Vuejs application (the only difference is that I replace the 'require' statements with " import {Database, aql} from 'arangojs' " ), it returns :
Failed to load http://localhost:8529/_db/mydb/_api/cursor: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Credentials' header in the response is 'false' which must be 'true' when the request's credentials mode is 'include'. Origin 'http://localhost:8080' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
Could it be that the ' db.useBasicAuth('root', 'degfra'); ' does not work in the application? Or is there another concern about using arangojs in the Browser? Thank you for your help.