What am I doing wrong here? I think I might be a little confused about the file structure, and must have a simple variable mixed up somewhere in one of the files. I’m just getting an empty array from my subscribe.
This is what it looks like:
body.js
import Celebrities from "../api/celebrities.js";
/* Import the other templates*/
import "./celebrity.js";
…/api/celebrities.js
import {Mongo} from "meteor/mongo";
import "./methods";
const Celebrities = new Mongo.Collection('celebrities');
export default Celebrities;
if( Meteor.isServer ){
Meteor.publish('allCelebrities',function(){
return Celebrities.find({});
});
}
body.js
/* When the body is created*/
Template.body.onCreated(function(){
// Subscribe to the item
Meteor.subscribe('allCelebrities');
body.js
/* The helpers for this body*/
Template.body.helpers({
celebrities: function(){
return Celebrities.find();
},
Does this code look correct? If I run a find()
from the console I have no issues.