how to use
Meteor.call(‘fun_name’) is sync ?
code
Template.article.helpers({
article_type(){
return Meteor.call('article_type')
}
})
console.log(Meteor.call(‘article_type’)) is undefined
how to use
Meteor.call(‘fun_name’) is sync ?
code
Template.article.helpers({
article_type(){
return Meteor.call('article_type')
}
})
console.log(Meteor.call(‘article_type’)) is undefined
Template.article.onCreated(function articleOnCreated() {
this.articleType = new ReactiveVar();
Meteor.call('article_type', (err, res) => {
if (err) {
// handle error
} else {
this.articleType.set(res);
}
});
Template.article.helpers({
article_type() {
return Template.instance().articleType.get();
}
});
You will need to meteor add reactive-var
and import { ReactiveVar } from 'meteor/reactive-var';
if you haven’t already done so.
thanks