javascript - Promises are not working in componentDidMount -
i new react.js
. in componentdidmount
function, calling 4 functions parallelly using q
module. in every function, making api
. once got responses 4 services,i want trigger 1 more function. have written following logic.
var q=require("q"); componentdidmount: function () { var self=this; this.setstate({loader:true}); q.all([this.getsegmentinfo(),this.getsignedurl(),this.getoverrallmyntrametricinfo(),this.getsegmentmetricinfo()]).then( function(result){ self.makedataformetrics(); },function(error){ utils.togglemessage(true,"sorry services failed.. try again","verror"); } ); }
the problem was, after got response services. dependent callback not triggering.
all parallel functions looks like
getsignedurl:function(){ var promiseinfo1=q.defer(); //making service using ajax return promiseinfo1.promise; }
can me, why dependent function not triggering.
thanks.
Comments
Post a Comment