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.getAsync('http://www.google.com') .then(function(resp){ return resp.body; }) .catch(function(err){ thow err; }); } I want to take this value and dump it to a file: var fs = require('fs'); Promise.promisifyAll(fs); getValue().then(fs.writeFileAsync, "file.html"); The problem is that fs.writeFileAsync expects parameter one to be