Relative Content

Tag Archive for javascriptnode.js

TypeError: Cannot read properties of undefined (reading ‘productsModel’)

Type Error: Cannot read properties of undefined (reading ‘products Model’)
at exports.getHome (E:ONLINE.SHOPcontrollershome.controller.js:20:31)
at Layer.handle [as handle_request] (E:ONLINE.SHOPnode_modulesexpresslibrouterlayer.js:95:5)
at next (E:ONLINE.SHOPnode_modulesexpresslibrouterroute.js:149:13)
at Route.dispatch (E:ONLINE.SHOPnode_modulesexpresslibrouterroute.js:119:3)
at Layer.handle [as handle_request] (E:ONLINE.SHOPnode_modulesexpresslibrouterlayer.js:95:5)
at E:ONLINE.SHOPnode_modulesexpresslibrouterindex.js:284:15
at Function.process_params (E:ONLINE.SHOPnode_modulesexpresslibrouterindex.js:346:12)
at next (E:ONLINE.SHOPnode_modulesexpresslibrouterindex.js:280:10)
at Function.handle (E:ONLINE.SHOPnode_modulesexpresslibrouterindex.js:175:3)
at router (E:ONLINE.SHOPnode_modulesexpresslibrouterindex.js:47:12enter image description here

How do I export a function in a non-Node environment in JavaScript

I am making a full stack ecommerce site with HTML, SCSS, Javascript, Node, Express and MongoDB. I have an addToCart() function in the catalog.js file, because the logic is that when the customer clicks the cart button, it should add the item to the cart.html file.