user1025852 user1025852 - 5 months ago 7
Node.js Question

node.js promise - passing params in a chain?

getAccountPromise
returns some ID response.
How exactly do I pass this variable to the next function in the promise chain?

var Promise = require('promise');
exports.createCampaign = function createCampaign(tokens, url, fund, insights)
{
var a = helper.getAccountPromise(tokens);
a.then(helper.getFundingPromise())
....

Answer

I think your problem is that you call helper.getFundingPromise and pass its resulting promise as callback into your promise chain. Just get rid of the parentheses so that you pass the function itself as callback.

var Promise = require('promise');
exports.createCampaign = function createCampaign(tokens, url, fund, insights)
{
    var a = helper.getAccountPromise(tokens);
    a.then(helper.getFundingPromise)
    ....
Comments