Created
August 9, 2017 15:32
-
-
Save AlexDenisov/45f63dc3981b56de594e3d1da8c6305f to your computer and use it in GitHub Desktop.
Promise/Monk bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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