Skip to content
Advertisement

Livewire invalid arrow-function arguments on action

I’m testing out Livewire with a Laravel shopping cart plugin. To add items to the cart you call a function, passing in id, name, quantity, price, and an optional array of metadata:

JavaScript

The rendered HTML looks perfect, but when I click the button I get:

JavaScript

It doesn’t seem to like the => in the array assignment. Does anyone know a fix?

Advertisement

Answer

there is no such thing as an associative array in javascript, it’s an object and as such you need to provide a valid object (if you still want it with the same structure).

JavaScript

or

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement