I’d like to access variable inside Meteor.call().
Here, I have numStudys inside Meteor.call(), and console.log() inside Meteor.call correctly shows the value of numStudys (in my case, 4, which is correct), but console.log() outside Meteor.call just keep showing “undefined”.
Is there any ways that I can access numStudys inside Meteor.call, and get the value (in my case, 4)?
export default class StudyPage extends React.Component {
constructor(props) {
super(props);
}
componentDidMount() {
Tracker.autorun(() => {
Meteor.call('studys.count', (error, result) => {
numStudys = result;
console.log("numStudys inside Meteor.call: ", numStudys);
});
console.log("numStudys outside Meteor.call: ", this.numStudys);
});
}
}
My result
numStudys outside Meteor.call: undefined
numStudys inside Meteor.call: 4