Server-side controller
Before we enrich the component with the code of the search movies functionality, we need to define some server-side actions. Due to several limits in regards to making callouts from the JavaScript in Lightning components, Salesforce recommends that we perform the callouts on an external system in an Apex class and call this class and method from a JavaScript controller/helper.
We wrote our search callout in Chapter 5, Apex - Beyond The Basics, and we want to reuse this logic. (We don't want to rewrite the same logic for the Lightning component.) We will call this function in a new Apex controller, which can be called by the Lightning Component framework. But why another controller?
The Lightning Component framework ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access