简体   繁体   中英

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())
    ....

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)
    ....

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM