Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper way to pass parameters from client to server #339

Open
Steve1820 opened this issue Jun 3, 2019 · 5 comments
Open

Proper way to pass parameters from client to server #339

Steve1820 opened this issue Jun 3, 2019 · 5 comments

Comments

@Steve1820
Copy link

Steve1820 commented Jun 3, 2019

Hey guys,

I've been struggling with this for days. I have my server set up as:

Meteor.publish('quests_filtered', (id) => { return Quests.find({'_id': id}); });

And my client like the below. You can think of quests exactly like a to do list.

export default withTracker(params => { Meteor.subscribe('quests_filtered', params.id); return { quests: Meteor.collection('quests_filtered').find({'_id': id}), }; })(QuestFeed);

The collection is defined as:

const Quests = new Mongo.Collection('quests');

However this.props.quests in the client side still returns the whole Quests collection and not those filtered by id.

I am at a complete loss - any ideas?

@Nauzer
Copy link
Contributor

Nauzer commented Jun 3, 2019

In your publish query there is _id and in your client query there is id. Guess that could cause some discrepancy.

@Steve1820
Copy link
Author

@Nauzer Thanks I updated my post and fixed it in my code but the problem still persists.

Is it working in your projects?

@Nauzer
Copy link
Contributor

Nauzer commented Jun 3, 2019

Haven't used the library in a while... but I think so.

On the client you should query 'quests' collection, not the publication name.
Meteor.collection('quests').find({'_id': id})

Do you have 'autopublish' turned off on your Meteor server?

@Steve1820
Copy link
Author

I dont have autopublish turned off - will this affect behaviour?

Apologies for being an absolute noob.

@Steve1820
Copy link
Author

@Nauzer thanks it worked!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants