As the title suggest I want to send data, collection in this case, to the client side through and then display it.
So what I’ve done is creating a publications file that’s imported into the server in main.js, it grabs the collection I was the client side to receive as publishes it.
import Links from '../collections/links.js';
Meteor.publish('links', function(){
return Links.find({});
});
and later on into my template file where I want everything to be display I import and but I get an error in the console telling me that Links isn’t global
Given that you’re using import/export for mudules you should really use export const Links = new Mongo.Collection("links");. Also, you said this in your OP:
a publications file that’s imported into the server in main.js
However, the only main.js I see in your folder structure is under client/, not server/.
You basically need to import { Links } from '/imports/api/collections/links'; in your server code and in your client code. The server part is necessary to ensure that a physical MongoDB collection is created for you. The client part is to ensure your pub/sub delivers data from server to client.
You don’t actually need the autorun in your onCreated - that’s only needed if your subscription references reactive variables in its parameter list for the publication. It won’t do any “harm” - it’s just unnecessary.
I did as you suggest (exporting Links constant) but the error persisted, as for the main.js, if you actually expanded the image, you’d find another main.js in server folder. I don’t just import everything directly into it, I import it into the startup/server/index.js file then import that index.js into the main one.