I have Meteor.call method on template onCreated method, which basically gets the data from an api to load a dropdown control however when i route to other view and comeback it makes an api call again. How to avoid these sorry i couldn’t get much info on this.
Please help.
Sample code of my client onCreated and helpers
On my client,
Template.userForm.onCreated(function userFormOnCreated() {
const template = this;
template.loadCountry = new ReactiveVar(null);
Meteor.call(‘loadCountries’, function (err, resp) {
if (err) {
console.log(err);
} else {
template.loadCountry.set(resp.Countries);
}
});
});
Template.userForm.helpers({
countryList: function () {
return Template.instance().loadCountry.get();
},
});