Swap Order Of Arguments To "then" With Bluebird / Nodejs Promises
I have a function which asynchronously grabs a value from a server: var request = require('request'); Promise.promisifyAll(request); function getValue(){ return request.getAsyn
Solution 1:
The second parameter to the .then()
function is an error callback, not a parameter. Your code doesn't work at all.
Instead, you can use .bind
to pre-bind a parameter:
getValue().then(fs.writeFileAsync.bind(null, "file.html"));
Note that the first parameter to .bind()
is the this
parameter, which doesn't matter.
Post a Comment for "Swap Order Of Arguments To "then" With Bluebird / Nodejs Promises"