Is there a nicer way to do the following in Node.JS using a promise:
var y = "...";
promise.using(getDatabaseConnection() function(connection) {
return connection
.query("some sql")
.then(function(result) {callAnotherFunction(result, y);}
.catch(function(error) {callAnotherFunction(error, y);}
});
This works, but is a bit clunky looking/hard to read. I have tried:
.then(callAnotherFunction.bind(null, y))
As suggested in another SO post and
.then(callAnotherFunction(y))
Just hoping for a really simple solution, but neither worked.
Thanks!
via William Moore
No comments:
Post a Comment