[Vuejs]-Vue filter Type Error and Render

0👍

Filter comes from Array.prototype.filter() which can only be invoked on Arrays, not on any Object. When you initialize your state variable, you are saying productsShop: {} with {} being the shorthand initialization for an empty object, instead of [] which would give you an empty array.

Whether this solves your problem or not entirely depends on the rest of the code. As for the error you had initially, this is the reasoning.

0👍

Filter is only be invoked on Arrays!

Leave a comment