[solved] Access package collection from main app

Hey all,

So I’m trying to build my own shopping cart. Currently what I’m doing is I have two packages: Products, and MyCart . I plan on subscribing to the cart and them making changes to it through the MyCart class I have imported in from the package. I also currently have the collection stored in the package as well.

I have added the package and imported it, yet the application its self can not find the collection created in the project, I get:

Exception in template helper: ReferenceError: Cart is not defined

Cart is the name of the collection used by the package, declared as:

Cart = new Mongo.Collection('cart')

How can I get my main app to recognize the Cart collection defined by the package? I have it loaded vir

  api.addFiles([
    'collections/cart-collection.js',
    
  ], ['client', 'server'])

The code I was missing was:

  api.export('Cart',['server','client']);

in my package.js file.

1 Like