0

I managed to create an helper that returns the data of a Collection once it's published from the server.

However I don't manage to retrieve the data by using Meteor.call (i.e. Collection server-side).

This is my code:

client/template.html

<template name="showScannedData">
     <!- .... more code -->
    {{myUserNetId}}
</template>

client/helpers.js (the one that works)

Template.showScannedData.helpers({
    'myUserNetId': function(){
       return Individuals.findOne().netId; // WORKS
    }
});

client/helpers.js (the one that does not work, i.e. blank output)

Template.showScannedData.helpers({
      return Meteor.call('getmyUserNetId', function(err,res){
          return res;
      });
    }
});

server/db_methods.js

Meteor.methods({
    getmyUserNetId: function(){
        return Individuals.findOne({}).netId;
    }
})
dragonmnl
  • 14,578
  • 33
  • 84
  • 129
  • You are returning Meteor.call and its empty at time of call, you need to return some value in callback – sdooo Sep 01 '15 at 14:06
  • Your helper still needs to be formatted in the way your first one is. Moreover, you cannot synchronously return an asynchronous value. You will need to set a Session variable or any ReactiveVar in the callback of the Meteor.call() – forallepsilon Sep 01 '15 at 18:36

0 Answers0