You must pass a link to the .then() function so that your options are as follows:
- Use the built-in anonymous function like you.
- Create your own utility function that returns another function (see example below)
- Use
.bind() to create another function.
Built-in Anonymous
some_function().then(function () { return query.apply("SELECT `whatever` FROM `wherever` ") }).then()
Your own shell of functions
function queryWrap(q) { return function() { return query.apply(q); } } some_function() .then(queryWrap("SELECT `whatever` FROM `wherever` ")) .then()
This shell can be useful if you can use it in several places. Probably not worth it for a single call.
Use .bind ()
some_function() .then(query.apply.bind(query, "SELECT `whatever` FROM `wherever` ")) .then()
source share