How to assign the results of Meteor.call to a variable-Meteor -
this question has answer here:
- blaze template iterate on object 2 answers
- how return response asynchronous call? 21 answers
if have following code:
meteor.call('/firsturl/abcd', xxx, function(err, result) { if (err) { //... } else { meteor.call('/secondurl/acde', zzz, function(err, result) { if (err) { //.. } else { valueneeded=result } }); } }); console.log(valueneeded) //undefined
how variable
valueneeded
outside asynchrnous call ?
see blaze template iterate on object (also applicable situation, not within blaze template)
with meteor, can use reactivevar
receive result of asynchronous call. if code makes use of within reactive scope (like tracker.autorun
), re-executed when data arrives.
this assumes can live code being executed several times (initially while call still pending response, once completes)
Comments
Post a Comment