I am working on a “online-shop” project using Fuse and an homemade API, in order to learn how to use fuse.
The part I am having troubles is the “cart”, I have a file with an observables and I add a product whenever the add button is clicked.
When I use product.name in the UX no problem; But cannot use it in the javascript file.
// Here with product I Get the name, price etc ...
var product = productView.Parameter.flatMap( function(param) {
//console.log("Current product id " + param._id);
return (param);
});
//what I want to do is add this product "object" to my observable (list), as show below
function addtobucket() {
dataStore.paniers.add(this.product);
console.log("Content of the cart JSON --> " + JSON.stringify(dataStore.paniers)); // NULL because this.product is undefined
}
I have tried many differents ways to add this product, following recommendations etc … Like make a copy with “var copie = Object.assign({}, obj);”