I do have a template and i'm trying to display a variable which should be modified from a method
Heres how my code looks like
The html
{{test}}
The server:
if (Meteor.isServer) {
Meteor.methods({
callApi: function (term) {
this.unblock();
try {
const result = HTTP.call('GET', 'https://www.googleapis.com/youtube/v3/search')
return result;
} catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range.
console.log(e);
return false;
}
}
});
}
The client
Template.body.helpers({
test: 'test'
});
Template.body.events({
'submit .media-Search'(event, template) {
// Prevent default browser form submit
event.preventDefault();
// Get value from form element
const target = event.target;
const text = target.text.value;
Meteor.call("callApi", text, function(error, results) {
if (error)
console.log(error);
template.test = results.data.items[0].snippet.channelId; //results.data should be a JSON object
});
// Clear form
target.text.value = '';
},
});
The variable does change but the change is not shown on the html page, What am i doing wrong?
Much appreciated!