Today has been a challenging day for me. I have encountered several related topics while trying to solve my issue, but unfortunately, I haven't been able to fix it yet. Being relatively new to Meteor, I have removed autopublish and am not sure if I am approaching the problem in the correct way.
In an attempt to address the issue, I created the collection as a const in the lib/import folder, which is shared between the client and server. Subsequently, I called a server method inside an Async function to insert data into the collection. As of now, everything seems to be working fine, as I can see the data in MongoDB.
Now, in the client.js file, I aim to handle each piece of data associated with a user and either append it to the template or perform other actions.
// SERVER
Meteor.publish("pipeline", function() {
var data = pipeline.find({}, {fields: {userID:this.userID}}).fetch();
return data;
});
// CLIENT
var loadCurrentPipeLineUser = Meteor.subscribe('pipeline');
var data = pipeline.findOne({userID: Meteor.userId()});
console.log(loadCurrentPipeLineUser);
console.log(data);
Unfortunately, both loadCurrentPipeLineUser
and data
are returning undefined. The output of loadCurrentPipe
(which seems to indicate undefined) is:
https://i.sstatic.net/QgbEy.png
Interestingly, on the server side within the publish function, everything appears correctly in the console.