[Solved]Assigning value to a variable in a Meteor Call Callback


Hi All,

I am trying to set the value of a variable in a Meteor call callback. each time when it try i get

Exception in delivering result of invoking 'Transaction': TypeError: Cannot set property 'killjoy' of undefined

Transaction -Meteor Method
Killjoy is the variable.

This is how my code looks like

Meteor.call('Transaction', {}, function(err, response) {
      if (err) {
        // handle error
      } else {
        this.state.killjoy = response;


I am expecting a response of the meteor call to be available globally for other function to follow.
can this be done ?


You should change the callback to an arrow function to get the behavior I’m guessing you want. Otherwise “this” will just be the window.



Thank you it did the trick