How to assign the results of Meteor.call to a variable-Meteor -


this question has answer here:

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

Popular posts from this blog

vue.js - Create hooks for automated testing -

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

serial port - hub4com OVERRUN Error -