-
Notifications
You must be signed in to change notification settings - Fork 53
Description
Adding process.env.NODE_ENV = 'development'; to a node.js application causes a warning similar to this one appearing:
Warning: .then() only accepts functions but was passed: [object Undefined], [object Undefined]
at Operation.operationResultPromise (/Users/tamaspiros/Desktop/projects/marklogic/node_modules/marklogic/lib/mlrest.js:1571:18)
at Object.callBackMethod as result
at selectOneDocument (/Users/tamaspiros/Desktop/projects/marklogic/app.js:14:33)
at Object. (/Users/tamaspiros/Desktop/projects/marklogic/app.js:25:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
Regardless of this warning the data is still returned. You can test this by running the following sample code:
var marklogic = require('marklogic');
var connection = {
host: 'localhost',
port: XXXX, //port
user: 'admin',
password: 'admin'
};
var db = marklogic.createDatabaseClient(connection);
var selectOneDocument = function() {
var uri = XXX; //replace with VALID URI
return db.documents.read(uri).result();
};
var resolve = function(document) {
console.log(document);
};
var reject = function(error) {
console.log(error);
}
selectOneDocument().then(resolve, reject);
Modifying the code to the following yields no warnings:
var resolve = function(document) {
console.log(document);
};
var reject = function(error) {
console.log(error);
}
var selectOneDocument = function() {
var uri = 'XXXX'; //URI
db.documents.read(uri).result(resolve, reject);
};
selectOneDocument();
This behaviour has been noticed after upgrading the nodejs-client-api from v1.0.1 to v1.0.2