js
if (Meteor.isClient) {
Template.body.helpers({
fixtures: function () {
Meteor.call("checkTwitter", function(error, results) {
return results.data.fixtures;
});
}
});
}
if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
});
Meteor.methods({
checkTwitter: function () {
this.unblock();
var url = "http://api.football-data.org/alpha/teams/73/fixtures";
return Meteor.http.call("GET", url);
}
});
}
html
<body>
<h1>Tottenham Hotspur</h1>
<button>Click Me</button>
<table class="table">
<th>
<td>Date</td>
<td>Home</td>
<td>Result</td>
<td>Away</td>
</th>
<tr>
{{#each fixtures}}
{{> fixture}}
{{/each}}
</tr>
</table>
</body>
<template name="fixture">
<td>{{date}}</td>
<td>{{home}}</td>
<td>{{result}}</td>
<td>{{away}}</td>
</template>
I am having trouble displaying the list of fixtures for a football team. I have created a helper function to call the API for the fixtures and return the data as an array called 'fixtures'. However, my template is not rendering the fixtures. When I check the console, 'results.data.fixtures' returns an array of objects. Can anyone spot what I am doing incorrectly?
Do you have any suggestions on how to fix this issue?