I have a client that have this helper:
Template.eventTemplate.helpers({
returnUsersEvents: function(){
Meteor.call("events.getByUserId", function(error, result){
if(error){
console.log("error" + error.reason);
return;
}
console.log(result);
return result;
});
}
});
The method on collection
Meteor.methods({
'events.insert'(Event) {
Events.insert(Event);
},
'events.getByUserId'(){
var events = Events.find({UserId: Meteor.userId()}).fetch();
console.log(events);
return events;
}
})
I have one object in my collection. But I retrieve three objects of the same type. Can anyone tell me what I am doing wrong?
Here is my template
<ul class="demo-list-item mdl-list">
{{#each returnUsersEvents}}
<li class="mdl-list__item">
<span class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect">
<i class="material-icons mdl-list__item-icon">map</i>
<a class="" href="/event/{{_id}}">{{EventName}}</a>
</span>
</li>
{{/each}}
</ul>