Send Arrays from LWC to Apex Methods
Let's look at how to send arrays from LWC to Apex methods
Sending data to LWC components is not straightforward in Lightning. However, major heavy lifting is done by the framework for us.
When we send primitive data it's pretty much straightforward.
Then comes the million dollar question, how can we send an Array from LWC to an Apex Controller.
When we send an Array in LWC it will be received as a List in Apex.
Here is the sample code!
Here is the Apex method, notice that the param is of type List.
We don't have to do anything, the framework is going to automatically map it for us.
Also, make sure the variable name is similar to that of the key of the object in @wire
decorator of LWC component.
Hope this is helpful!
I have put together a FREE course on Javascript that helps you master Lightning Web Components.
It just takes 2 hours to finish the course and you will be able to feel the difference.