Salesforce Platform Developer I (legacy) — Question 156
A developer migrated functionality from JavaScript Remoting to a Lightning web component and wants to use the existing getOpportunities() method to provide data.
Which modification to the method is necessary?
Answer options
- A. The method must return a String of a serialized JSON Array.
- B. The method must be decorated with (cacheable=true).
- C. The method must be decorated with @AuraEnabled.
- D. The method must return a JSON Object.
Correct answer: C
Explanation
The correct answer is C because Lightning web components require methods to be exposed to the component's JavaScript, which is accomplished by decorating them with @AuraEnabled. Options A, B, and D are incorrect as they do not address the requirement for exposing the method to the Lightning web component framework.