Angular: Cannot read property 'length' of undefined

But instead of %22, there are quotation marks.

Well,
Why don’t you debug your code to see if the variables are being assigned and if the parameters are coming correctly?
Apparently an object is returning in params {} (right? Taking this part that you showed params.length or after the return of that part const checkoutRef = this.db.list ('cart_checkouts')) if this is the case you cannot push in an object or length, there are no such object methods, only arrays. * The URL does not have much sense to pass since it has no way to run to test. It would be easier to solve this problem if you could pass the repository . ok ( if open project ) :+1:t5:

Thanks JorgeLAB for the suggestions.

I debugged like this:


console.log("params " + params);
console.log("this.checkouts " + this.checkouts);
console.log("this.items HERE " + this.items);
console.log("params.checkouts " + params.checkouts);
const item = JSON.parse(params.checkouts);
console.log("item.product_name " + item.product_name);
console.log("params checkouts product_name " + params.checkouts["product_name"]);

and the console log returned:


params [object Object]
this.checkouts undefined
this.items HERE undefined
params.checkouts [{"id":1,"thumbnail":"product-2.gif","quantity":2,"product_name":"Adult Female Bike","product_price":20.5},{"id":3,"thumbnail":"product-4.gif","quantity":3,"product_name":"Adult Unisex Helmet","product_price":4}]
item.product_name undefined
params checkouts product_name undefined

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.