How to pass multiple data context via template helpers?

I have a form in my template to edit a product and I also load some categories from mongo to show in select options, when I access ‘this’ in my template events, it returns an empty object and this._id is undefined.

Template.editproduct.helpers({
     product() {
        const productId = Router.current().params._id;
        return Products.findOne({_id: productId});
    },
    categories() {
        return Categories.find({});
    }
});

How do would I be able to access a particular data context with ‘this’ in my events. And what’s the best way of passing multiple data context to a template?

We need more information about your editproduct template to be able to provide you with solutions on what the context might look like.

Confirm you’ve subscribed to Products and Categories.

In your template make sure categories list is wrapped in {{#each categories}} {{/each}}

And product stuff would be wrapped in a {{#with product}} {{/with}}

if that does not solve your issue we would need more info.

1 Like

Yeah, this was what I later did and it worked. Thanks