Skip to content

Instantly share code, notes, and snippets.

@AlexDenisov
Created August 9, 2017 15:32
Show Gist options
  • Save AlexDenisov/45f63dc3981b56de594e3d1da8c6305f to your computer and use it in GitHub Desktop.
Save AlexDenisov/45f63dc3981b56de594e3d1da8c6305f to your computer and use it in GitHub Desktop.
Promise/Monk bug
var monk = require('monk');
var promise = require('promise');
function connect() {
return new promise( function (resolve, reject) {
monk('mongodb://localhost:27017/monk', function (error, db) {
if (error) {
console.log('about to reject');
reject(error);
} else {
console.log('about to resolve');
resolve(db);
}
});
});
}
connect()
.then( function (db) {
console.log(db);
})
.catch( function (error) {
console.log(error);
});
{
"name": "promise_monk",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"monk": "^6.0.3",
"promise": "^8.0.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment