Meteor.publish is not a function

I have a publications.js file that ONLY includes

Meteor.publish('org', function(_id){ return Organizations.findOne(_id); }); 

When things are displayed, I get this in the console:

 Uncaught TypeError: Meteor.publish is not a function 

What I'm missing here ... I'm sure this is painfully obvious.

+6
source share
2 answers

You probably accidentally use the code on the client. You have two options:

  • Put the publish code in a file in the /server directory in your application.
  • Wrap above inside the if (Meteor.isServer) {} block.

(1) Does it have the advantage of not passing the publication code to the client.

Recommended reading: Structuring your application .

+14
source

If the file is in the root directory, you need to wrap it:

if ( Meteor.isServer ) { /* ... */ }

The Meteor.publish method exists only on the server.

+1
source

All Articles