Paste your code between triple backticks like this:
```
paste your
code here
```
Okay, let’s try and fix this step-by-step.
- Database fixtures.
The usual way to set up your collection with some predefined content is in the server’s Meteor.startup()
.
In server/main.js
Meteor.startup(() => {
if (Category.find().count() === 0) {
[
{
name: 'IT',
sub_categories: [
'Java',
'PHP',
'.NET',
'Android/iOS',
'HTML/CSS',
'Java script and Framworks',
'Ruby on Rail',
],
},
{
name: 'ENGLISH',
sub_categories: [
'Listening', 'Speaking', 'Writting', 'Reading', 'Toeic',
],
},
{
name: 'SoftSkill',
sub_categories: [
'CV and CL', 'Presentation', 'Teamwork',
],
},
{
name: 'ENTERTAISMENT',
sub_categories: [
'Sports', 'Games', 'Music & Videos', 'Fashion', 'Talk show',
],
},
].forEach(doc => {
Category.insert(doc);
});
}
});
- Publish your data
In server/publish.js
:
Meteor.publish('categories', function() { // Don't use () => { here or you will lose the context.
return Category.find(); // Do not use fetch() - in a publish you need to return a cursor, not an array
});
- Subscribe to your publication
In client/postSubmit.js
:
Template.postSubmit.onCreated(function() { // Don't use () => { here or you will lose the context.
// You should be using a template subscription.
// If you use a global (Meteor.subscribe) you will also have to deal with stopping this subscription when you've finished with it.
this.subscribe('categories');
});
- Set up your template helpers
In client/postSubmit.js
:
Template.postSubmit.helpers({
categories() => {
return Category.find({ name: this.name });
},
subCategory() => {
return Meteor.settings.public.subCategory;
},
});
- Check your template
I’m unclear what you’re trying to achieve here, but {{this}}"
looks wrong.